• PerformEraseBackground 擦除背景(ThemeServices)


    PerformEraseBackground 擦除背景的简单方法(外带ThemeServices例子)
     
    在查这个函数的时候,顺便看到了有趣的代码。
    怎么使用 Themes 。
    
    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,UxTheme;
    {$R *.dfm}
    { TVSPanel }
    procedure TVSPanel.Paint;
    var
      Details: TThemedElementDetails;
    begin
      inherited;
      if ThemeServices.ThemesEnabled then
      begin
        Details := ThemeServices.GetElementDetails(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;
    View Code

  • 相关阅读:
    spoj 3273 Treap
    hdu1074 Doing Homework
    hdu1024 Max Sum Plus Plus
    hdu1081 To the Max
    hdu1016 Prime Ring Problem
    hdu4727 The Number Off of FFF
    【判断二分图】C. Catch
    【01染色法判断二分匹配+匈牙利算法求最大匹配】HDU The Accomodation of Students
    【数轴涂色+并查集路径压缩+加速】C. String Reconstruction
    【数轴染色+并查集路径压缩+加速】数轴染色
  • 原文地址:https://www.cnblogs.com/key-ok/p/3380483.html
Copyright © 2020-2023  润新知