Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IDI_ICON1

Status
Not open for further replies.

Kiehlster

MIS
Aug 14, 2000
147
US
I keep getting an undeclared identifier (error C2065) whenever I change this:

wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);

to this:

wc.hIcon = LoadIcon(NULL,IDI_ICON1);

I've created a resource.rc file that contains IDI_ICON1 and added it to my project, but I keep getting the same error over and over. It works fine with internal icons, but not with icons that I create. Anyone have any idea? Steve Kiehl
webmaster@nanovox.com
 
It's not sufficient to only add the .rc file. IDI_ICON1 should also be defined in a header (check out your resource.h, its filled with those defines). Also, it's not necessary to create an external rc for our own icons (unless you want to use them in several apps, maybe...). You can just add them to the ones being already there.
Greetings,
Rick
 
So how would I go about doing this in MSVC++? Whenever I add the resource.h file that comes along with the resource.rc file, I get an error when calling:

LoadIcon(NULL, IDI_ICON1)

The error I get is:

error C2664: 'LoadIconA' : cannot convert parameter 2 from 'const int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Steve Kiehl
webmaster@nanovox.com
 
Okay, I've got it loading the icon, but for some reason, the program doesn't display the icon as the window's caption icon. The icon does show up as the icon for the EXE file that it compiles. Any idea why it's not using the icon as the program window icon? Steve Kiehl
webmaster@nanovox.com
 
Did you assign it to the window as the icon?
I don't know if you're usin MFC or straight APIs to create your windows. With MFC I believe it's CWnd::SetIcon. Else it's to be added to the WND_CLASS structure, or set by SendMessage and the WM_SETICON message.
Greetings,
Rick
 
Nevermind... I figured out from some old code that I need to map it to an instance:

LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));

- rather than -

LoadIcon(NULL,IDI_ICON1);

Gotta love how you answer your own questions when you're waiting around for an answer. But now I have a pretty little icon for my application. [smile] Steve Kiehl
webmaster@nanovox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top