You are here:

C++/Window Icons

Advertisement


Question
Hi 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

Answer
Hello 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

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.