Public Group

# icons in dev-c

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

## Recommended Posts

Hello, A simple question, perhaps? I am trying to change the default icon in a simple windows program. I get no compile errors, but the icon hasn't changed when i run it. I have a simple rc file with the line: jonicon ICON C:\Dev-Cpp\book.ICO and then in the main program i have winclass.hIcon = LoadIcon(NULL, "jonicon"); The program compiles with no errors, but when it runs the icon in the upper corner, or when minimized is still the default icon. I noticed something else strange: When i change the line winclass.hIcon = LoadIcon(NULL, "jonicon"); to winclass.hIcon = LoadIcon(NULL, "aaaajonicon"); it still compiles without error even though there is no icon named aaajonicon. Does anybody have any suggestions? Thanks

##### Share on other sites

Try changing your code to this:
    winclass.hIcon  = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(jonicon));    winclass.hIconSm  = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(jonicon), IMAGE_ICON, 16, 16, 0);

##### Share on other sites
Try this:
//icon.h (or similar)#define jonicon 101//in the resource file#include "icon.h"...jonicon ICON "C:\Dev-Cpp\book.ICO"//in the code#include "icon.h"...winclass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(jonicon));

Also, I had a problem similar to this when I had two resource files. The second one was getting compiled, but the app couldn't find the resources it defined. Since it defined the icon resource, my icon was never being used. Once I finally put all the resource definitions in one file, it magically worked properly.

##### Share on other sites
First, I have to say i am very impressed by this forum. There is alot of knowledge here, and people are VERY helpful.

But,alas, i still cant seem to get this to work. I will play with it for a couple more days, and let you know what happens. Thanks for the help!

Jonathan

##### Share on other sites
Quote:
 Original post by jon_gamedevFirst, I have to say i am very impressed by this forum. There is alot of knowledge here, and people are VERY helpful.But,alas, i still cant seem to get this to work. I will play with it for a couple more days, and let you know what happens. Thanks for the help!Jonathan

Try posting all your relevent code.

##### Share on other sites
I got it all figured out. I appreciate the kind help and advice given, but i must admit it was a silly mistake on my part. The way i first described doing the icons DOES work in DEV-C..

my mistake was somehow putting another winclass.hIcon statement that reloaded the default icon after i loaded my custom icon. Next time, i will take more time to check my code for such silly mistakes before i ask for help. Sorry.

Jonathan

• 18
• 11
• 16
• 9
• 50
• ### Forum Statistics

• Total Topics
631396
• Total Posts
2999783
×