• Welcome to Valhalla Legends Archive.
 

Retrieving a Handle to an Icon

Started by Mephisto, September 26, 2004, 06:10 PM

Previous topic - Next topic

Mephisto

How would you get a handle to an icon so you can use it in the SendMessage() function set an icon on a console application?

Spht

Quote from: Mephisto on September 26, 2004, 06:10 PM
How would you get a handle to an icon so you can use it in the SendMessage() function set an icon on a console application?

See WM_GETICON.

Mephisto

That's for getting an icon from the window associated with it isn't it?  I need a method for getting a handle to an icon via the file name if this is possible.

l)ragon

HICON hIcon = ExtractIcon((HINSTANCE)GetModuleHandle(NULL),(char*)"filepath\icofile.ico",0);

Would this be what you want?
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Mephisto

Quote from: dRAgoN on September 26, 2004, 08:33 PM
HICON hIcon = ExtractIcon((HINSTANCE)GetModuleHandle(NULL),(char*)"filepath\icofile.ico",0);

Would this be what you want?

I already tried using that function earlier.  It needs to be the same type as the SetMessage function; typecasting doesn't seem to work.  Lookup WM_SETICON, and maybe you can tell me from looking at the required arguments.

Eibro

Use LoadIcon if the icon is compiled into your executable.
Eibro of Yeti Lovers.