How can I use the ListView_GetBkImage macro:
http://msdn.microsoft.com/en-us/library/bb761246(v=VS.85).aspx
... from a C#/WinForms application? I think this macro just wraps the SendMessage
method, but I'm not sure. I couldn't find any C#-based samples on this.
Basically I'm trying to get a LVBKIMAGE ( http://msdn.micros开发者_运维知识库oft.com/en-us/library/bb774742(v=VS.85).aspx ) structure that references the Desktop's background bitmap.
You cannot. A macro is processed at compile time by the C/C++ compiler, but you want to access the binary library. You will just have to find the macro in the source, see what it does and do the same in your C# code. It shouldn't be anything too complex. Download the Platform SDK if you don't already have it and look in the .h file mentioned in the documentation.
Edit: OK, so the macro is defined as:
#define ListView_GetBkImage(hwnd, plvbki) \
(BOOL)SNDMSG((hwnd), LVM_GETBKIMAGE, 0, (LPARAM)(plvbki))
SNDMSG
is simply defined as SendMessage
. LVM_GETBKIMAGE is an integer - it's 0x1045 for the ASCII version and 0x108B for the Unicode version. (You probably want the Unicode version if you're unsure.) So the entire thing resolves to:
(BOOL)SendMessage(hwnd, 0x108B, 0, plvbki)
There should be easy enough to map to C#. Look in System.Windows.Forms using Reflector to see how Microsoft have imported the SendMessage function. It will be marked internal, so you cannot call it, but you can copy it. plvbki
is a pointer to a struct - you'll need to create a C# equivalent of LVBKIMAGE
. Actually, MS have probably done that for you too, so look around for that.
精彩评论