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, );
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
APanel: TVSPanel;
begin
APanel := TVSPanel.Create(Application);
APanel.Left := ;
APanel.Top := ;
APanel.Width := ;
APanel.Height := ;
APanel.Caption := '具有 Button 风格的 Panel';
APanel.Parent := Self;
end;

PerformEraseBackground 擦除背景(ThemeServices)的更多相关文章

  1. 具有 Button 风格的 Panel(覆盖TCustomPanel的Paint函数,用到了ThemeServices)

    unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  2. 解决Winform应用程序中窗体背景闪烁的问题

    本文转载:https://my.oschina.net/Tsybius2014/blog/659742 我的操作系统是Win7,使用的VS版本是VS2012,文中的代码都是C#代码. 这几天遇到一个问 ...

  3. WM_ERASEBKGND官方解释(翻译),以及Delphi里所有的使用情况(就是绘制窗口控件背景色,并阻止进一步传递消息)

    #define WM_ERASEBKGND                   0x0014 Parameters wParam A handle to the device context. //  ...

  4. 具有 Button 风格的 Panel

    unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  5. Delphi 完全时尚手册之 Visual Style 篇 (界面不错) 转自http://blog.csdn.net/iseekcode/article/details/4733229

    这里先说说两个概念:Theme(主题)和 Visual Style .Theme 最早出现在 Microsoft Plus! for Windows 95 中,是 Windows 中 Wallpape ...

  6. Delphi 完全时尚手册之 Visual Style 篇

    这里先说说两个概念:Theme(主题)和 Visual Style .Theme 最早出现在 Microsoft Plus! for Windows 95 中,是 Windows 中 Wallpape ...

  7. TForm的显示过程

    新建一个空窗体项目,然后运行,此时首先运行: procedure TApplication.Run; begin FRunning := True; try AddExitProc(DoneAppli ...

  8. 一行代码设置TForm颜色的前世今生(属性赋值引起函数调用,然后发消息实现改变显示效果),TForm的初始颜色在dfm中设置了clBtnFace色

    来自万一的帖子:http://www.cnblogs.com/del/archive/2008/04/27/1173658.html的确做到了一行代码设置TForm控件的颜色(一点感想:Delphi程 ...

  9. 研究一下TForm.WMPaint过程(也得研究WM_ERASEBKGND)——TForm虽然继承自TWinControl,但是自行模仿了TCustomControl的全部行为,一共三种自绘的覆盖方法,比TCustomControl还多一种

    先擦除背景: procedure TCustomForm.WMEraseBkgnd(var Message: TWMEraseBkgnd); begin if not IsIconic(Handle) ...

随机推荐

  1. makefile 使用 Tricks

    .phony是表示目标是伪目标,并不生成相应的文件..phony标志的文件总是执行的. 1. 短横(-)与@ @(常用在 echo 之前):make 在执行编译打包等命令前会在命令行输出此命令,称之为 ...

  2. Samsung_tiny4412(驱动笔记05)----Makefile,open,read,write,lseek,poll,ioctl,fasync

    /*********************************************************************************** * * Makefile,op ...

  3. 关于Linux前后台进程切换

    前言: 当使用SSH远程登录服务器时,对于运行时间较长的程序(如Caffe的训练可能需要十几个小时), SSH可能会在很长时间后断掉,导致程序没运行完就中断了. 为了解决这个问题,需要将在服务器运行的 ...

  4. HDU - 5157 :Harry and magic string (回文树,求多少对不相交的回文串)

    Sample Input aca aaaa Sample Output 3 15 题意: 多组输入,每次给定字符串S(|S|<1e5),求多少对不相交的回文串. 思路:可以用回文树求出以每个位置 ...

  5. 梯度下降法、牛顿法、高斯牛顿法、LM最优化算法

    1.梯度下降法 2.牛顿法 3.高斯牛顿法 4.LM算法

  6. Light OJ 1199:Partitioning Game(SG函数模板)

    Alice and Bob are playing a strange game. The rules of the game are: 1.      Initially there are n p ...

  7. 玩vue+mockjs

    玩vue+mockjs vue中用mock制造模拟接口(本文主要解决坑),一定要看完哦 最近新入职一家公司,后端造接口速度很慢,想来想去还是搞一套模拟接口,来满足开发需求,有人会问,我造一个死数据不就 ...

  8. Redis和MySQL的结合方案

    转载:http://m.blog.csdn.net/article/details?id=50586990 方案一: 程序同时写Redis和MySQL读Redis 方案二: 程序写MySQL, 使用G ...

  9. centos 7.0 lnmp成功安装过程(很乱)

    下载nginx [root@localhost src]# wget http://nginx.org/download/nginx-1.7.9.tar.gz --2015-01-24 12:55:2 ...

  10. 使用btrace需要注意的几个问题

    1. @ProbeClassName String clazz 此处String不能写为java.lang.String 2. location=@Location(Kind.RETURN) publ ...