码迷,mamicode.com
首页 > 其他好文 > 详细

XP风格

时间:2014-09-17 01:05:31      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   log   on   c   ef   r   res   

unit Unit1;
//加上这句和下边的{$R WindowsXP.res} 相当于放了一个xp风格组件,激活了风格
{$WEAKPACKAGEUNIT ON} //弱引用,参见编译指令
interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Themes;
//引用 Themes 单元,此单元中提供一组服务,用来调用系统的 uxtheme.dll 风格库
//其中提供了各种空间风格的绘制函数,具体调用可参见 Thems 单元

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

TMyThemsControl = class(TPanel)
private
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
protected
procedure Paint; override;
end;

var
Form1: TForm1;
{$R WindowsXP.res}
implementation

{$R *.dfm}

{ TMyThemsControl }

procedure TMyThemsControl.Paint;
var
Details: TThemedElementDetails;
begin
inherited;
//获取一种风格
Details := ThemeServices.GetElementDetails(themes.tbPushButtonNormal);
ThemeServices.DrawElement(Canvas.Handle, Details, Self.ClientRect, nil);
end;


procedure TMyThemsControl.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
//判断服务是否开启
if ThemeServices.ThemesEnabled then
Message.Result := 1
else
DefaultHandler(Message);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
b: TMyThemsControl;
begin
b := TMyThemsControl.Create(self);
b.Parent := Self;
end;

end.

XP风格

标签:io   ar   for   log   on   c   ef   r   res   

原文地址:http://www.cnblogs.com/spiritofcloud/p/3976183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!