1
votes

is there a Win32 API to construct a HICON handle that contains icons in multiple sizes from pixel data stored in memory? I know that I can construct single icons from memory pixel data using CreateIconIndirect() but these icons will always contain just one size but I want to construct a single HICON handle that contains icons in 16x16, 24x24, 32x32, 48x48 and 256x256 for use with RegisterClassEx().

I know I could simply use a resource icon or load an external *.ico but that's all not possible for my specific case. I need to be able to construct this multiple image HICON from memory pixel data.

The only solution that comes to my mind is to create a temporary *.ico file on disk and then load it using LoadIcon() but that is not a nice solution.

That's why I'd like to ask if there's an API to construct a multi-image HICON from memory pixel data?

Thanks!

1
Why do you think that HICON contains all icons?Xearinox
Because RegisterClassEx() only gets a single HICON handle from me and still Windows uses different icons for my application depending on the context (taskbar icon, tab cycling icon, window border icon...). Windows seems to get this all from the single HICON handle I pass to RegisterClassEx() so there must be multiple images in it.Andreas
No WNDCLASSEX use two hicons - normal and small.Xearinox
@What may see? I am wrote exactly thing as David.Xearinox
Icons created from resources remember what resource they came from and can go back to the original resource if resizing is needed. Icons created from memory have nowhere to go back to.Raymond Chen

1 Answers

1
votes

No there is not. An HICON contains a single image. There is no such thing as a multi-image HICON.

You can supply two separate icons when you call RegisterClassEx. You supply both large and small icons in the WNDCLASSEX structure. Which is all you need because the only icons that are associated with a window are the large and small icons.