Author: William Gerbert
How do I change the color of the tabs on a PageControl?
Answer:
The example below uses the OnDrawCell event to change the colour of the active Tab
and of the Font used:
1 2 procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
3 TabIndex: Integer; const Rect: TRect; Active: Boolean);
4 var5 s: string;
6 r: TRect;
7 begin8 s := form1.TabControl1.Tabs.Strings[tabindex];
9 r := Rect;
10 with Control.Canvas do11 begin12 if Active then13 begin14 Brush.Color := clinfoBK;
15 Font.Color := clBlue;
16 end;
17 Windows.FillRect(Handle, r, Brush.Handle);
18 OffsetRect(r, 0, 1);
19 DrawText(Handle, PChar(s), Length(s), r, DT_CENTER or DT_SINGLELINE or20 DT_VCENTER);
21 end;
22 end;