Custom Icons: Not working with MinGW

I tried icon "iconNAME.ico" in a resource file (im not stupid, i did it right) but it could not use the icon file for some reason. Since I can't figure it out, I would like to ask the experience programmer how to do this with CB + MinGW. IM NOT CHANGING THE SHORTCUT ICON. Just making sure you got that. ;D
You have not assigned any resource id to that icon. See MSDN for resource files syntax.
When you do it right, then use LoadImage to load the icon and fill up WNDCLASSEX structure accordingly.
... seriously... just give me the format for the dang icon.
pleaaasssse. I've searched all over for this and i can't get it to work. :'(((

i use Code::Blocks with MinGW. I want to do this for a consol program but it says the syntax is wrong.
Last edited on
ok, i searched and searched... i created a 32x32 .ico PNG file, included it in my project, did this with a resource file:

MAINICON ICON "journal.ico"

and the dam thing gives me this:

||icon file `journal.ico' does not contain icon data|
||=== Build finished: 1 errors, 0 warnings ===|

yeah, no sh** sherlock! I know it doesn't have that data, its a picture!

back to you guys...
I'm losing my patients. I've searched and searched for about 3 hours and i found nothing that I haven't tried to fix my problem. I've checked the compiler, formated the dam .ico in png, 24-bit, 16-bit, and now we're at 32 by 32 pixels. IM LOSING MY MIND! Why wont C::B just compile the dam thing? Based on my research it uses winres.exe to do it and it doesn't seem to be doing that.

PLEASE ONLY POST IF YOU HAVE A RESOLUTE ANSWER, thanks in advance! Seriously... thanks so so so so so so much... >;< my head might explode if you don't hurry! (jk)
Last edited on
O.K.
Let us see

You have 3 files: main.cpp (the file where WinMain is located), the resources.rc (the file where your resources are defined) and the resources.h(where you assign an ID for each resource).

--resources.rc--
 
MAINICON ICON "iconNAME.ico"


--resources.h--
 
#define MAINICON     101 


--main.cpp--
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "resources.h";

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nCmd) {

// Now, when you define your window class

 WNDCLASSEX wcex;

    wcex.cbSize         = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = main_proc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInst;
    wcex.hIcon          = LoadIcon(hInst, MAKEINTRESOURCE(MAINICON));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszClassName  = "Window Title";
    wcex.hIconSm        = LoadIcon(hInst, MAKEINTRESOURCE(MAINICON));

}


Try to implement this
My research showed i do not need to create a GUI to include a custom Icon. This is for a consol program.

Thank you though, i do appreciate your advice.
Last edited on
Your icon will only be shown in windows explorer, not in console window or taskbar then.

You could include icons and other resources in console programs too, this is correct.
look, i did my research. IT CAN BE DONE. All I want is for the icon not to be generic. I haver about 10 consol programs I've created and i would like to compile an Icon with each of them so i dont accededentally click the wrong one.
Last edited on
There are some independent applications that can create and change the icons of your .exe files like Exe Icon Changer, ResEdit or IcoFX. You can use them after creating your file.
Last edited on
Straightforward:

How to change icon of C++ console app?

http://www.daniweb.com/software-development/cpp/threads/121245
that didnt work:

||icon file `journal.ico' does not contain icon data|
||=== Build finished: 1 errors, 0 warnings ===|

i tried includeing the .ico in my project, i tried excluding it from my project, i tried to compile the dam thing (the .ico independently, theoretically creating a .o. it doesnt do that...), nothing seems to work.
Last edited on
am i supposed to use command prompt to compile the icon or somthing?
I figured it out. After giving up with paint, i just searched for a 3rd party software. Some how, paint (even though saved as an icon) doesn't save it in the right icon format. I got iconFX and got it all workin well. Sorry for the trouble, haha.

Thanks to all of you who tried to answer my question.
Now you see - if you were better at asking questions and explaining your issues - I (we) could
have told you that MS Paint is no good for making ICON files.
I didn't think it was an issue witht the icon format, lol. I feel like an idiot. I was using paint to create 32, 32 pixel *.ico files, but for some reason, they weren't in a "special" format. I am not quite sure what IconFX does to make it compatable... the results are practically the same: 32, 32 pixel .ico files.
Last edited on
There is something wrong with your icon then. I used myself windows 7 Paint to convert .png or .jpg to .ico and it worked without issues, the icon is displayed correctly.
hmm... There can't be anything wrong... it's 32, 32 pixel .png formatted *.ico file. Mabey it has to do with vista, because i upgraded to W7 from windows Vista. Vista pisses me off, genuinly pisses me off. This wouldnt be the first time either. would be, though, since the upgrade...
Topic archived. No new replies allowed.