procedure TForm1.PageControlDrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
y : Integer;
x : Integer;
aRect: TRect;
begin
Control.Canvas.Font.Color := clWindowText;
if TabIndex = 0 then
Control.Canvas.Font.Color := clRed;
if TabIndex = 1 then
Control.Canvas.Font.Color := clBlue;
if TabIndex = 2 then
Control.Canvas.Font.Color := clBlack;
if TabIndex = 3 then
Control.Canvas.Font.Color := clGreen;
if TabIndex = 4 then
Control.Canvas.Font.Color := clFuchsia;
if Active then
begin
//Fill the tab rect
Control.Canvas.Brush.Color := clBtnFace;
Control.Canvas.FillRect(Rect);
//Fill the background
aRect.Left:=1;
aRect.Right:=Control.Width-1;
aRect.Bottom:=Control.Height-1;
aRect.Top:=Rect.Bottom+1;
Control.Canvas.FillRect(aRect);
end
else
begin
//Fill the tab rect
Control.Canvas.Brush.Color := clBtnFace;
Control.Canvas.FillRect(Rect);
end;
y := Rect.Top + ((Rect.Bottom – Rect.Top – Control.Canvas.TextHeight(TTabControl(Control).Tabs[TabIndex])) div 2) + 1;
x := Rect.Left + ((Rect.Right – Rect.Left – Control.Canvas.TextWidth (TTabControl(Control).Tabs[TabIndex])) div 2);
//draw the tab title
Control.Canvas.TextOut(x,y,TTabControl(Control).Tabs[TabIndex]);
end;