Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Mephisto on September 26, 2004, 06:10 PM

Title: Retrieving a Handle to an Icon
Post by: 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?
Title: Re: Retrieving a Handle to an Icon
Post by: Spht on September 26, 2004, 06:37 PM
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.
Title: Re: Retrieving a Handle to an Icon
Post by: Mephisto on September 26, 2004, 07:18 PM
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.
Title: Re: Retrieving a Handle to an Icon
Post by: l)ragon on September 26, 2004, 08:33 PM
HICON hIcon = ExtractIcon((HINSTANCE)GetModuleHandle(NULL),(char*)"filepath\icofile.ico",0);

Would this be what you want?
Title: Re: Retrieving a Handle to an Icon
Post by: Mephisto on September 26, 2004, 10:20 PM
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.
Title: Re: Retrieving a Handle to an Icon
Post by: Eibro on September 27, 2004, 06:47 AM
Use LoadIcon if the icon is compiled into your executable.