- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对 GetThemeStream 很困惑功能
HRESULT GetThemeStream(
_In_ HTHEME hTheme,
_In_ int iPartId,
_In_ int iStateId,
_In_ int iPropId,
_Out_ VOID **ppvStream,
_Out_ DWORD *pcbStream,
_In_ HINSTANCE hInst
);
如何使用这个功能?我应该将哪个参数传递给 ppvStream
?
更新:
我正在尝试将它与 delphi 一起使用,来自 UxTheme 的声明:
function GetThemeStream(hTheme: HTHEME; iPartId: Integer; iStateId: Integer;
iPropId: Integer; var ppvStream: Pointer; var pcbStream: DWORD;
hInst: HINST): HResult; stdcall;
var
h: HTHEME;
Res: HResult;
PBuf, PPBuf: Pointer;
BufSize: Cardinal;
h := OpenThemeData(Handle, 'DWMWINDOW');
if h = 0 then Exit;
PBuf := nil;
PPBuf := @PBuf;
Res := GetThemeStream(h, WP_FRAMELEFT, CBS_HOT, TMT_DISKSTREAM, PPBuf, BufSize, hInstance);
if Res <> S_OK then Exit;
这里我有 BufSize = 75005,Res = S_OK,但 PBuf 中没有任何内容(nil),可能是我发送的参数不正确吗?
最佳答案
此函数的正确用法,感谢程序作者 Andreas Verhoeven Vista Style Builder :
var
hTh: HTHEME;
hLib: HMODULE;
DllName: string;
Png: TPngImage;
MS: TMemoryStream;
BufSize: Cardinal;
PBuf: Pointer;
hTh := OpenThemeData(...);
// DllName is path to the theme file
hLib := LoadLibraryEx(PChar(DllName), 0, LOAD_LIBRARY_AS_DATAFILE);
// Read Theme Png stream
GetThemeStream(hTh, 0, 0, TMT_DISKSTREAM, PBuf, BufSize, hLib);
// Copy data to memory stream
MS := TMemoryStream.Create;
MS.WriteBuffer(PByteArray(PBuf)^[0], BufSize);
MS.Position := 0;
// Copy memory stream to Png
Png := TPngImage.Create;
Png.LoadFromStream(MS);
更新更多示例:
var
ThemeRectLeft,
ThemeRectLeftInactive,
ThemeRectMiddle,
ThemeRectMiddleInactive,
ThemeRectCloseRight,
ThemeRectCloseRightInactive,
ThemeRectCloseSingle,
ThemeRectCloseSingleInactive,
ThemeRectMinIco,
ThemeRectMaxIco,
ThemeRectRestoreIco,
ThemeRectHelpIco,
ThemeRectCloseIco: TRect;
var
THEME_MIDDLE_IMAGES : Integer = 3;
THEME_MIDDLE_IMAGES2 : Integer = 4; // Inactive Window
THEME_LEFT_IMAGES : Integer = 5;
THEME_LEFT_IMAGES2 : Integer = 6; // Inactive Window
THEME_CLOSE_RIGHT_IMAGES : Integer = 7;
THEME_CLOSE_RIGHT_IMAGES2 : Integer = 8; // Inactive Window
THEME_CLOSE_SINGLE_IMAGES : Integer = 9;
THEME_CLOSE_SINGLE_IMAGES2 : Integer = 10; // Inactive Window
THEME_CLOSE_HOT_FRAME : Integer = 11; // Win7, Vista
THEME_HOT_FRAME : Integer = 16; // Win7, Vista
THEME_CLOSE_ICONS : Integer = 12;
THEME_HELP_ICONS : Integer = 16; // Win7, Vista: 17
THEME_MAX_ICONS : Integer = 20; // Win7, Vista: 21
THEME_MIN_ICONS : Integer = 24; // Win7, Vista: 25
THEME_RESTORE_ICONS : Integer = 28; // Win7, Vista: 29
THEME_CLOSE_SMALL_IMAGES : Integer = 37; // Win7, Vista: 45
THEME_CLOSE_SMALL_IMAGES2 : Integer = 38; // Win7, Vista: 46 Inactive Window
THEME_CLOSE_SMALL_HOT_FRAME : Integer = 47; // Win7, Vista
THEME_CLOSE_SMALL_ICONS : Integer = 39; // Win7, Vista: 48
function LoadThemePng(var APng: TPngImage; const APathToSave: string): Boolean;
const
ThemeRegPath = 'SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager';
var
hTh: HTHEME;
hLib: HMODULE;
DllName, Path: string;
MS: TMemoryStream;
BufSize: Cardinal;
PBuf: Pointer;
I: Integer;
Rt: TRect;
imgPng: TPngImage;
begin
Result := False;
hTh := OpenThemeData(0, 'DWMWINDOW');
if hTh <> 0 then
try
// Get Library path
SetLength(DllName, 1024);
SHRegGetPath(HKEY_CURRENT_USER, PChar(ThemeRegPath), 'DllName', PChar(DllName), 0);
// Open Library
hLib := LoadLibraryEx(PChar(DllName), 0, LOAD_LIBRARY_AS_DATAFILE);
if hLib > 0 then
try
// Read Theme Png stream
if GetThemeStream(hTh, 0, 0, TMT_DISKSTREAM, PBuf, BufSize, hLib) = S_OK then begin
MS := TMemoryStream.Create;
try
MS.WriteBuffer(PByteArray(PBuf)^[0], BufSize);
MS.Position := 0;
APng.LoadFromStream(MS);
Result := True;
finally
MS.Free;
end;
end;
finally
FreeLibrary(hLib);
end;
GetThemeRect(hTh, THEME_LEFT_IMAGES, 0, TMT_ATLASRECT, ThemeRectLeft);
GetThemeRect(hTh, THEME_LEFT_IMAGES2, 0, TMT_ATLASRECT, ThemeRectLeftInactive);
GetThemeRect(hTh, THEME_MIDDLE_IMAGES, 0, TMT_ATLASRECT, ThemeRectMiddle);
GetThemeRect(hTh, THEME_MIDDLE_IMAGES2, 0, TMT_ATLASRECT, ThemeRectMiddleInactive);
GetThemeRect(hTh, THEME_CLOSE_RIGHT_IMAGES, 0, TMT_ATLASRECT, ThemeRectCloseRight);
GetThemeRect(hTh, THEME_CLOSE_RIGHT_IMAGES2, 0, TMT_ATLASRECT, ThemeRectCloseRightInactive);
GetThemeRect(hTh, THEME_CLOSE_SINGLE_IMAGES, 0, TMT_ATLASRECT, ThemeRectCloseSingle);
GetThemeRect(hTh, THEME_CLOSE_SINGLE_IMAGES2, 0, TMT_ATLASRECT, ThemeRectCloseSingleInactive);
if (Win32MajorVersion = 6) and (Win32MinorVersion in [0, 1]) then begin
GetThemeRect(hTh, THEME_MIN_ICONS + 1, 0, TMT_ATLASRECT, ThemeRectMinIco);
GetThemeRect(hTh, THEME_MAX_ICONS + 1, 0, TMT_ATLASRECT, ThemeRectMaxIco);
GetThemeRect(hTh, THEME_RESTORE_ICONS + 1, 0, TMT_ATLASRECT, ThemeRectRestoreIco);
GetThemeRect(hTh, THEME_HELP_ICONS + 1, 0, TMT_ATLASRECT, ThemeRectHelpIco);
end
else begin
GetThemeRect(hTh, THEME_MIN_ICONS, 0, TMT_ATLASRECT, ThemeRectMinIco);
GetThemeRect(hTh, THEME_MAX_ICONS, 0, TMT_ATLASRECT, ThemeRectMaxIco);
GetThemeRect(hTh, THEME_RESTORE_ICONS, 0, TMT_ATLASRECT, ThemeRectRestoreIco);
GetThemeRect(hTh, THEME_HELP_ICONS, 0, TMT_ATLASRECT, ThemeRectHelpIco);
end;
GetThemeRect(hTh, THEME_CLOSE_ICONS, 0, TMT_ATLASRECT, ThemeRectCloseIco);
if APathToSave <> '' then begin
Path := IncludeTrailingPathDelimiter(APathToSave);
APng.SaveToFile(Path + 'Theme_Full.png');
for I := 1 to 99 do begin
imgPng := TPngImage.Create;
try
if GetThemeRect(hTh, I, 0, TMT_ATLASRECT, Rt) = S_OK then begin
CopyPng(APng, imgPng, Rt);
imgPng.SaveToFile(Path + 'Theme_Img_' + IntToStr(I) + '.png');
end;
finally
imgPng.Free;
end;
end;
end;
finally
CloseThemeData(hTh);
end;
end;
关于c - GetThemeStream 用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34222021/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我有实体: @Entity @Table(name = "CARDS") public class Card { @ManyToOne @JoinColumn(name = "PERSON_I
我正在尝试计算二维多边形的表面法线。我正在使用 OpenGL wiki 中的 Newell 方法来计算表面法线。 https://www.opengl.org/wiki/Calculating_a_S
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我这里有以下 XML: Visa, Mastercard, , , , 0, Discover, American Express siteonly, Buyer Pay
即将发生的 Google 政策变更迫使我们实现一个对话框,以通知欧盟用户有关 Cookie/设备标识符用于广告和分析的情况。我只想向欧盟用户显示此对话框。我不想使用额外的权限(例如 android.p
本文分享自华为云社区《华为大咖说 | 企业应用AI大模型的“道、法、术” ——道:认知篇》,作者:华为云PaaS服务小智。 本期核心观点 上车:AGI是未来5~10年内,每个人都无法回避的技
我有一个与酒精相关的网站,需要先验证年龄,然后才能让他们进入该网站。我使用 HttpModule 来执行此操作,该模块检查 cookie,如果未设置,我会将它们重定向到验证页面。我验证他们的年龄并存储
在欧盟,我们有一项法律,要求网页请求存储 cookie 的许可。我们大多数人都了解 cookie 并同意它们,但仍然被迫在任何地方明确接受它们。所以我计划编写这个附加组件(ff & chrome),它
以下在 C 和/或 C++ 中是否合法? void fn(); inline void fn() { /*Do something here*/ } 让我担心的是,第一个声明看起来暗示函数将被定义
我是一名优秀的程序员,十分优秀!