views:

30

answers:

1

I am trying to use an HIMAGELIST from an unmanaged dll which gives me the result as an IntPtr.

Is there a way for me to turn this IntPtr into a Bitmap or an Image so I can use it for Winforms buttons, as in:

myButton.Image = intPtrImage
+1  A: 

You need to call ImageList_GetIcon for each image in the list - this will give you an HICON which is easy to load into a Bitmap

Paul Betts
Thanks, after that how can I load HICON into an Image? Using Bitmap.FromHbitmap? But HICON is also gonna be IntPtr?
Joan Venge
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.fromhicon.aspx
Paul Betts
Thanks, also I am stuck at the flags parameter of ImageList_GetIcon. How can I specify it? I think I need ILD_NORMAL.
Joan Venge
I found it, it was public const int ILD_NORMAL = 0x0000;
Joan Venge