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
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, XPMan;
type
TForm1 = class(TForm)
XPManifest1: TXPManifest;
TabControl1: TTabControl;
procedure FormCreate(Sender: TObject);
procedure TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
uses uxTheme,Themes;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
//Désactive le Theme sur le TabControl
SetWindowTheme(TabControl1.Handle,'','');
end;
//évènement OnDrawTab du TabControl
procedure TForm1.TabControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var Details: TThemedElementDetails;
i,j:integer;
TC:TTabControl;
ARect:TRect;
ThemedTab:TThemedTab;
begin
if not(Control is TTabControl) then exit;
TC:=(Control as TTabControl);
Details:= ThemeServices.GetElementDetails(ttTabRoot);
ThemeServices.DrawElement(TC.Canvas.Handle,Details,Control.ClientRect);
Details:= ThemeServices.GetElementDetails(ttBody);
ThemeServices.DrawElement(TC.Canvas.Handle,Details,Control.ClientRect);
Details:= ThemeServices.GetElementDetails(ttPane);
ThemeServices.DrawElement(TC.Canvas.Handle,Details,Control.ClientRect);
for i:=0 to TC.Tabs.Count-1 do
begin
ARect:=TC.TabRect(i);
if TC.TabIndex=i
then ThemedTab:=ttTabItemLeftEdgeSelected
else ThemedTab:=ttTabItemLeftEdgeNormal;
Details:= ThemeServices.GetElementDetails(ThemedTab);
ThemeServices.DrawElement(TC.Canvas.Handle,Details,ARect);
TC.Canvas.Brush.Style:=bsClear;
//à la place de ceci, tu peux mettre du code pour afficher du texte avec un angle à 90 :
TC.Canvas.TextOut(ARect.Left+2,ARect.Top+2,TC.Tabs[i]);
end;
end;
end. |