0

So in the program I'm writing, I'm using a TPageControl component with multiple tab sheets. I want to change the color of the tab of the sheet that is currently the active page on the PageControl and then have the color be reset after clicking on another page (then that tab will change due to it being the active page and so on...), to make navigating the page control a bit easier. But I'm not sure how to do it? I did try using the OnChange procedure of the page control and some code like this (I know it's horribly wrong but I ran out of ideas and google searches. It didn't work anyway.):

with pgcTabs.ActivePage do
begin 
brush.color:=clBlue;
font.color:=clWhite;
end; 

Thanks in advance for the help!
Kind Regards
PrimeBeat

PrimeBeat
  • 444
  • 5
  • 15

1 Answers1

2

You can't. Apart from using TTabSheet.Highlighted you have no control over how the tabs are displayed.

Or you have to fully draw it yourself, as usual as for most other controls: set TPageControl.OwnerDraw to true, then use the OnDrawTab event to paint whatever you want to. It should be identical to TTabControl.OnDrawTab (see answer). The drawbacks (pun intended) of painting everything yourself is usually all the extra work to do: checking dimensions, interpreting accelerator keys, respecting system colors and settings (i.e. LTR)...

In my opinion "just adding a color" has little to no value compared to how the control by default paints already with all its advantages and features. Consider color blindness: those people might rather have problems.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31