Icon Creation

Started by
8 comments, last by Omega147 18 years, 1 month ago
I want a custom icon for my prog. How can I do this? I already created a basic icon(called "Icon.ico") on paint shop pro, but how can I import it to my program? Thanks; ~S of the L~ edit: Sorry, I am using Dev C++ on windows XP [Edited by - Servant of the Lord on March 1, 2006 11:18:01 PM]
Advertisement
When you're setting up your WNDCLASS or WNDCLASSEX strut prior to creating your main program window, there is a member variable called hIcon (and hIconSm for WNDCLASSEX). If you then have your icon loaded into the project as a resource, you can load the icon by calling the LoadIcon function. It goes something like this...
WNDCLASSEX wndEx;wndEx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_OF_ICON_HERE));

And that should do it...
I am making a basic text rpg and using the console window; so I don't set up any windows. How do I do it for that?

And I have my icon loaded in Icon.rc as

A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "Icon.ico"

I got that from another program; is this the correct way to do so?
Oh, and also: I want part of the icon clear or see-through, so I made that part blue 255, red 0, green 0, so how do I input that also?
To put an icon on the console window... I have no idea how to do that. I don't think you can do that (someone correct me on that?). As for the see-through part, in the dev C++ icon editor deal, there should be a background/alpha color that you can paint with, and then just as long as the icon contains that, the alpha-ing should be processed automatically.

Edit: Hrm... well, I just tested somethin'. I created a shortcut on my desktop, pointing to the windows command prompt deal ("cmd.exe"), and then in the properties of the shortcut I changed the icon there. After that, running the shortcut opens the command window with that icon. So, one solution to your problem would be to just do that for your executable manually (you can change the icons on those too, same way as you do a shortcut on the desktop). And... that should work.
You can't I think assign an icon to a Windows terminal window, but you can assign it to the batchfile or exe which starts the terminal by modifying the shortcut.
You can I believe also add an icon to a Win32 terminal application by assigning a resource file to it and loading from that compiletime, but I've not done so in ages.
Once you get the HWND of your console you ought to be able to set the icon to it with SendMessage and WM_SETICON.

There is the GetConsoleHWND but it's only available in Win2000 upwards (meaning you have to define WINVER to 0x0500).

There are other hackish ways to find your HWND: Set a special text and use FindWindow to retrieve the HWND.

Mind you i didn't try that with the console window (setting the icon), but from my experience it should work.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Using Visual Studio, you can just add an icon resource to your project and it will do it for you. Maybe Dev-C++ has an add resource menu?
Thanks for the help everyone; I'm still alittle lost, though. [embarrass]


Quote:Original post by Omega147
Edit: Hrm... well, I just tested somethin'. I created a shortcut on my desktop, pointing to the windows command prompt deal ("cmd.exe"), and then in the properties of the shortcut I changed the icon there. After that, running the shortcut opens the command window with that icon. So, one solution to your problem would be to just do that for your executable manually (you can change the icons on those too, same way as you do a shortcut on the desktop). And... that should work.


I've done that with previous .exe files but I can't find out how to make them! I am so lost with this stuff; especially in termology(termanology?(Symbolism...sorry)). How do I load it into the computer's icon files; is there a certain folder I just stick it in or do I browse to it manually? Thanks again.

Quote:You can't I think assign an icon to a Windows terminal window, but you can assign it to the batchfile or exe which starts the terminal by modifying the shortcut.

Thats what I am trying to do; how might I do that? Did I even create my Icon right? I (when saving) added a '.ico' to the end as I saw another Icon named that. But do I also need to do something else to make my 'blue 255' color clear? Any help is wanted, needed, and thankful for.

Quote:You can I believe also add an icon to a Win32 terminal application by assigning a resource file to it and loading from that compiletime, but I've not done so in ages.

Thats what I tried at first by(not knowing how) looking at another program and imitating code. It didn't work as I did something wrong. But am not sure how or what,

In my program in Dev C++ 'project options' I browsed to my Icon in the correct way in the correct slot but the message that came up is: "Icon Image is not valid" is this because it's to big? Its '128 x 128' should it be '16 x 16' or '32 x 32'? Thanks for all your help everyone!
Quote:Original post by Servant of the Lord
I've done that with previous .exe files but I can't find out how to make them! I am so lost with this stuff; especially in termology(termanology?(Symbolism...sorry)). How do I load it into the computer's icon files; is there a certain folder I just stick it in or do I browse to it manually? Thanks again.
You should have an output folder or a base folder somewhere with your project. Find that, and in there (or around that area) you'll find a .exe file matching the name of your project. The icon you created should also be around there, saved as a .ico. Then yeah, with that executable you'll have to manually browse for and assign that icon to it (this is down outside of your dev environment, through windows explorer or whatever).

However, I completely forgot about the WM_SETICON message which Endurion mentions (see his post for more info). I would recommend doing it that way, as the program will assign the icon every time it runs, whereas if you were to do it manually as mentioned above, you'd have to reassign the icon every time you compiled the executable.

This topic is closed to new replies.

Advertisement