Ale*_*rov 7 winapi windows-themes
绘制主题按钮我使用此代码:
var
h: HTHEME;
begin
if UseThemes then begin
SetWindowTheme(Handle, 'explorer', nil);
h := OpenThemeData(Handle, 'WINDOW');
if h <> 0 then
try
DrawThemeBackground(h, Canvas.Handle, WP_CLOSEBUTTON, GetAeroState, ClientRect, nil);
finally
CloseThemeData(h);
end;
end
else
DrawFrameControl(Canvas.Handle, ClientRect, DFC_CAPTION, DFCS_CAPTIONCLOSE or GetClassicState)
end;
Run Code Online (Sandbox Code Playgroud)
此代码工作正常但绘制的按钮看起来像是从Windows 7主题,甚至在Windows 8或10上.这可以使用Windows 10或8主题绘制关闭按钮?
从主题获取位图的可行解决方案:
var
h: HTHEME;
Rect: TRect;
BufSize: Cardinal;
h := OpenThemeData(Handle, 'DWMWINDOW');
if h <> 0 then
try
GetThemeRect(h, WP_MINCAPTION, MNCS_ACTIVE, TMT_ATLASRECT, Rect);
...
GetThemeStream(...);
finally
CloseThemeData(h);
end;
Run Code Online (Sandbox Code Playgroud)
以及如何使用 GetThemeStream 描述如下:GetThemeStream 用法,非常感谢 Andreas Verhoeven,Vista Style Builder 程序的作者