The program won't use the icon i've stated.

Hey,

This is the code;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WNDCLASSEX wc;
     MSG Msg;
     wc.cbSize = sizeof(WNDCLASSEX);
	 wc.style = 0;
     wc.lpfnWndProc = WndProc;
     wc.cbClsExtra = 0;
     wc.cbWndExtra = 0;
     wc.hInstance = hInstance;
     wc.hIcon = LoadIcon(hInstance, "icon1.ico");
     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
     wc.hbrBackground = (HBRUSH)(BLACK_PEN, PS_DOT);
     wc.lpszMenuName = NULL;
     wc.lpszClassName = g_szClassName;
     wc.hIconSm = LoadIcon(hInstance, "icon1.ico");


As you can see, i've set the icon, but when i compile it to debug, it doesnt work?

Anyone know why?

Thanks! :-)

Did you include that icon in your application resource file? (extension .rc)
The follow is an example of what the entry should look like. The 100 is the ID, it can be any number that is unique within the .rc file.

100 ICON DISCARDABLE "icon1.ico"

If you want to load the icon through the ID instead of the name you could change the call to
LoadIcon( hInstance, MAKEINTRESOURCE( 100 ) );


I dont have an .rc file, i did it from scratch in a C++ project.

What else can i do?

Cheers :-)
You must have an RC file to use the LoadIcon function. If you do not want to use one of these, use the LoadImage function with LR_LOADFROMFILE flag specified.

http://msdn.microsoft.com/en-us/library/ms648045(VS.85).aspx
Topic archived. No new replies allowed.