function farbe(idx: integer): TColor;
begin
case idx of
0: result := clred;
1: result := cllime;
2: result := clyellow;
else result := clBtnFace;
end;
end;
procedure flaeche(tc: TCustomTabcontrol);
begin
with tc do
canvas.floodfill(3, height - 3, canvas.pixels[3, height - 3], fsSurface);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Tabcontrol1.ownerdraw := true;
Tabcontrol1.tabindex := 0;
// und zum Testen:
TabControl1.Tabs.Add('Reiter1');
TabControl1.Tabs.Add('Reiter2');
TabControl1.Tabs.Add('Reiter3');
end;
procedure TForm1.TabControl1Change(Sender: TObject);
begin
TTabcontrol(sender).canvas.brush.color :=
farbe(TTabcontrol(sender).tabindex);
flaeche(TTabcontrol(sender));
end;
procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var r: TRect;
begin
with control.canvas do begin
brush.color := farbe(tabindex);
if tabindex = 0 then flaeche(control);
r := rect;
fillrect(rect); // Reiterfarbe
brush.style := bsclear;
inflaterect(r, 0, -2);
drawtext(handle, pchar(TTabControl(control).tabs[tabindex]), -1, r,
dt_center or dt_vcenter or dt_singleline);
end;
end;