本文介绍了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使用它:

I'm trying to use it with delp declaration from 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(无),可能我是不正确发送参数?

Here I'm have BufSize = 75005, Res = S_OK, but nothing in PBuf (nil), possible I'm incorrect send parameter?

推荐答案

此功能的正确用法,感谢安德烈亚斯·范霍文,程序的:

Correct usage of this function, thanks to Andreas Verhoeven, author of the program 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);

这篇关于GetThemeStream用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 16:43