1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TPageControl = class(ComCtrls.TPageControl)
published
property TabHeight;
property TabWidth;
end;
TForm1 = class(TForm)
PageControl1: TPageControl;
procedure FormCreate(Sender: TObject);
procedure PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
private
// ...
public
// ...
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
PageControl1.OwnerDraw := True;
PageControl1.TabPosition := tpLeft;
PageControl1.TabHeight := 60;
PageControl1.TabWidth := 60;
end;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
TabText: string;
P: TPageControl;
OutRect : TRect;
begin
p := Control as TPageControl ;
TabText := TPageControl(P).Tabs[TabIndex];
// TabText := P.Pages[TabIndex].Caption;
OutRect := Rect;
InflateRect (OutRect, -3, -3);
OutRect.Left := OutRect.Left + 3;
if Active Then
begin
P.Canvas.Font.Color := clred ;
end
else
begin
P.Canvas.Font.Color := clBlack;
end;
DrawText (Control.Canvas.Handle,
PChar (ExtractFileName (TabText)),
Length (ExtractFileName (TabText)),
OutRect, dt_Left or dt_SingleLine or dt_VCenter);
end;
end. |
Partager