Jump to content
  • Advertisement
Sign in to follow this  

How to add an icon to Visual C++ Express application?

This topic is 4238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to add (replace default) icon for native Win32 application written in Visual C++ 2005 Express? Please help.

Share this post

Link to post
Share on other sites
I don't know if the express edition have an easy of doing it, but you can do in code by changing couple lines when you register the window class.

You probably have something like this when you init your window:

int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
WNDCLASS winclass;

winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
// This is the line you need to change.
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = CLASSNAME;

Make your icon as a resource for the project, then change the IDI_APPLICATION to whatever the new icon ID is. Also you'll need to use MAKEINTRESOURCE on the ID to make it work. Something like:

winclass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(NEW_ICON_ID));

Share this post

Link to post
Share on other sites
Thanks, that was very useful, but I have found that some more steps are needed to do this task. VC Express does not support resource edititng, so we must create them in an external editor:


#define IDI_ICON1 101

IDI_ICON1 ICON "icon_name.ico"

Add this rc file and ico file to the project and then perform steps as previously described.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!