Sign in to follow this  
jon_gamedev

icons in dev-c

Recommended Posts

jon_gamedev    139
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 this post


Link to post
Share on other sites
I suggest you read this.

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 this post


Link to post
Share on other sites
yckx    1298
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 this post


Link to post
Share on other sites
jon_gamedev    139
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 this post


Link to post
Share on other sites
Quote:
Original post by jon_gamedev
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

Try posting all your relevent code.

Share this post


Link to post
Share on other sites
jon_gamedev    139
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this