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

具有 Button 风格的 Panel

时间:2015-08-21 19:21:24      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, ExtCtrls;

type
  TForm2 = class(TForm)
    ImageList1: TImageList;
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TVSPanel = class(TCustomPanel)
  private
  protected
    procedure Paint; override;
  public

end;

var
  Form2: TForm2;

implementation

uses Themes;

{$R *.dfm}

{ TVSPanel }

procedure TVSPanel.Paint;
var
  Details: TThemedElementDetails;
begin
  inherited;
  if ThemeServices.ThemesEnabled then
  begin
    Details := ThemeServices.GetElementDetails(tttBaloonNormal{tbPushButtonHot});   {这里画个按钮处于 Hot 状态下的样子}
    PerformEraseBackground(Self, Canvas.Handle);      {擦除画按钮时的背景}
    ThemeServices.DrawElement(Canvas.Handle, Details, ClientRect);
    ThemeServices.DrawText(Canvas.Handle, Details, Caption, ClientRect,
      DT_EXPANDTABS or DT_VCENTER or DT_CENTER or DT_SINGLELINE, 0);
  end;
end;

procedure TForm2.FormCreate(Sender: TObject);
var
  APanel: TVSPanel;
begin
  APanel := TVSPanel.Create(Application);
  APanel.Left := 100;
  APanel.Top := 100;
  APanel.Width := 200;
  APanel.Height := 30;
  APanel.Caption := 具有 Button 风格的 Panel;
  APanel.Parent := Self;
end;

end.

参考:http://www.cnblogs.com/key-ok/p/3380535.html

具有 Button 风格的 Panel

标签:

原文地址:http://www.cnblogs.com/findumars/p/4748629.html

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