C++/Window Icons
Expert: Eddie - 10/5/2005
QuestionHi Eddie,
ive been mesing around using C++ (with Dev C++ ide) for a while now and have noticed in the window procedure that you can set the icon.
I noticed the default valuse was;
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
After some google bashing i managed to find this alternative;
wincl.hIcon = LoadIcon (NULL, IDI_ASTERISK);
wincl.hIconSm = LoadIcon (NULL, IDI_ASTERISK);
Which uses the Information icon (i in a speach bubble)
I am interested in using my own icons as a alternative icon.
Anyhelp on different windows icons or how to usemy own would be great
Thank you very much for the help
Gareth
AnswerHello Gareth, thank you for the question.
To load your own icon, you have to pass the hInstance of the class (not NULL) and a string to the path of your own icon file. You get the hInstance parameter as the first parameter of the WinMain function. Then in the call to LoadIcon, you can do the following:
winclass.hIcon = LoadIcon(hInstance, "nameOfImage.bmp");
I believe native Windows only supports bitmap images, so I would stick with those. For better reference than Google, try reading this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/win...
That is the MSDN instructions for that function. The MSDN is infinitely better than google, and you should refer to it first if possible. It can be used for free at:
http://msdn.microsoft.com
If you have any other questions, please do not hesistate to ask. I do have to go on vacation this weekend though and will not have internet access, but anything after Sunday will be fine.
I hope this information was helpful.
- Eddie