Einzelnen Beitrag anzeigen

madtom

Registriert seit: 24. Feb 2005
Ort: Hamburg
115 Beiträge
 
Delphi XE7 Professional
 
#2

AW: Farbige Schrift beim TPageControl Tab...

  Alt 6. Mai 2011, 21:41
Hallo,

folgender Code sollte den Zweck erfüllen:
(Quelle: http://www.delphi-treff.de/)

Delphi-Quellcode:
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
  CaptionX: Integer;
  CaptionY: Integer;
  TabCaption: string;
begin
  with Control.Canvas do begin
    case TabIndex of
      0: begin
           Brush.Color := clBtnFace;
           Font.Color := clWindowText;
         end;
      1: begin
           Brush.Color := clMaroon;
           Font.Color := clWhite;
         end;
    end;
    TabCaption := PageControl1.Pages[TabIndex].Caption;
    CaptionX := Rect.Left + ((Rect.Right - Rect.Left - TextWidth(TabCaption)) div 2);
    CaptionY := Rect.Top + ((Rect.Bottom - Rect.Top - TextHeight('Gg')) div 2);
    FillRect(Rect);
    TextOut(CaptionX, CaptionY, TabCaption);
  end;
end;
Thomas
Thomas
  Mit Zitat antworten Zitat