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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| unit TestTheme_Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, UxTheme;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DrawTheme(dc:HDC; iPartId, iStateId: integer; const R: TRect);
var
h: THandle;
s: WideString;
begin
S := 'button';
h := OpenThemeData(0, PWidechar(S));
DrawThemeBackground(h, dc, iPartId, iStateId, R, nil);
CloseThemeData(h);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
h: integer;
begin
h := canvas.Handle;
//Button
//Normal
DrawTheme(h, 1, 1, bounds(80 * 0, 10, 70, 30));
//Hot
DrawTheme(h, 1, 2, bounds(80 * 1, 10, 70, 30));
//Pushed
DrawTheme(h, 1, 3, bounds(80 * 2, 10, 70, 30));
//Disabled
DrawTheme(h, 1, 4, bounds(80 * 3, 10, 70, 30));
//Focused
DrawTheme(h, 1, 5, bounds(80 * 4, 10, 70, 30));
//OptionButton
//Normal
DrawTheme(h, 2, 1, bounds(80 * 0, 50, 70, 30));
//Hot
DrawTheme(h, 2, 2, bounds(80 * 1, 50, 70, 30));
//Pushed
DrawTheme(h, 2, 3, bounds(80 * 2, 50, 70, 30));
//Disabled
DrawTheme(h, 2, 4, bounds(80 * 3, 50, 70, 30));
//Fucused
DrawTheme(h, 2, 5, bounds(80 * 4, 50, 70, 30));
//CheckButton
//Normal
DrawTheme(h, 3, 1, bounds(80 * 0, 70, 70, 30));
//Hot
DrawTheme(h, 3, 2, bounds(80 * 1, 70, 70, 30));
//Pushed
DrawTheme(h, 3, 3, bounds(80 * 2, 70, 70, 30));
//Disabled
DrawTheme(h, 3, 4, bounds(80 * 3, 70, 70, 30));
//Fucused
DrawTheme(h, 3, 5, bounds(80 * 4, 70, 70, 30));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
InitThemeLibrary;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FreeThemeLibrary;
end;
end. |
Partager