Valhalla Legends Forums Archive | C/C++ Programming | Retrieving a Handle to an Icon

AuthorMessageTime
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?
September 26, 2004, 11:10 PM
Spht
[quote author=Mephisto link=topic=8865.msg82179#msg82179 date=1096240228]
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?
[/quote]

See WM_GETICON.
September 26, 2004, 11:37 PM
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.
September 27, 2004, 12:18 AM
dRAgoN
[code]HICON hIcon = ExtractIcon((HINSTANCE)GetModuleHandle(NULL),(char*)"filepath\icofile.ico",0);[/code]

Would this be what you want?
September 27, 2004, 1:33 AM
Mephisto
[quote author=dRAgoN link=topic=8865.msg82224#msg82224 date=1096248828]
[code]HICON hIcon = ExtractIcon((HINSTANCE)GetModuleHandle(NULL),(char*)"filepath\icofile.ico",0);[/code]

Would this be what you want?
[/quote]

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.
September 27, 2004, 3:20 AM
Eibro
Use LoadIcon if the icon is compiled into your executable.
September 27, 2004, 11:47 AM

Search