blacksun
blacksun

Reputation: 733

Changing VCL Styles on runtime

I am using Delphi XE5. I want to add VCL styles to one of my projects but having a problem. After I set the new vcl style, all handles change. For example i am having problem with listview if there are already items and if i have active tcp sockets, they don't work anymore. I need to restart app and choose the style on startup or i need to re-create everything but this is annoying. I can not paste any code now as i am out of my development pc. But i believe you have also faced this problem?

Can anyone tell me the best and safest way to change vcl syles on runtime?

Thanks

Upvotes: 0

Views: 371

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

Changing VCL styles at runtime results in window recreation. There's nothing you can do about that. Furthermore, window recreation is one of the realities of the VCL. Your program can face it at other times, when some other event leads to VCL window recreation. So, your problem is not really directly related to VCL styles. Rather your problem is that you are using for socket communications window handles whose lifetimes are shorter than they need to be.

The solution is to use window handles whose lifetimes you control. Use AllocateHWnd to create such window handles.

Upvotes: 4

Related Questions