Jump to content
Mark Williams

Custom component catching the pain process when theme enabled

Recommended Posts

I'm working on a component derived from a TTabControl. I want to manipulate the individual tabs in various ways. To do so I need to override the DrawTab event. This works well until you activate a theme and then the DrawTab event doesn't fire unless you disable seClient for styleElements., which I don't wish to do as I don't want to have to try and draw the body.

 

 If I add a TTabControl to a form and then access its OnDrawTab event, I can override the themed drawing of the tab with a theme active even though seClient styleElements is true.  

 

That seems a bit odd to me.

 

I have tried catching various paint messages and tab drawing messages, but nothing seems to fire in my custom control with seClient set to true.

 

Is there a way of doing this? 

Edited by Mark Williams

Share this post


Link to post
11 hours ago, Mark Williams said:

I'm working on a component derived from a TTabControl. I want to manipulate the individual tabs in various ways. To do so I need to override the DrawTab event. This works well until you activate a theme and then the DrawTab event doesn't fire unless you disable seClient for styleElements., which I don't wish to do as I don't want to have to try and draw the body.

 

 If I add a TTabControl to a form and then access its OnDrawTab event, I can override the themed drawing of the tab with a theme active even though seClient styleElements is true.  

 

That seems a bit odd to me.

 

I have tried catching various paint messages and tab drawing messages, but nothing seems to fire in my custom control with seClient set to true.

 

Is there a way of doing this? 

Try to add a class constructor and destructor to your custom control, like

class constructor TMyTabControl.Create;
begin
  TCustomStyleEngine.RegisterStyleHook(TMyTabControl, TTabControlStyleHook);
end;

class destructor TMyTabControl.Destroy;
begin
  TCustomStyleEngine.UnRegisterStyleHook(TMyTabControl, TTabControlStyleHook);
end;

Of course you need to use your component class name instead of TMyTabControl.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×