how to create an icon?

Oct 25, 2013 at 10:39pm
Hi guys.
Just realised that my windows program doesnt have an icon.
I do DirectX and no almost nothing about API GDI.

Can anybody give me some shortcut and dirty-and-quick code to set my Bitmap as icon.

I have a 32x32 pixel bitmap and a 16x16 one ready already
Thanks
Oct 25, 2013 at 11:04pm
closed account (Dy7SLyTq)
do you mean like what you see when you want to click the exe? you need to make a resource file
Oct 26, 2013 at 12:34am
This little program is very friendly:
http://www.angusj.com/resourcehacker/
Oct 26, 2013 at 3:24pm
GIMP is the first thing that comes to my mind for converting something into ICO.
Various other image viewers do the job; like IrfanView or FastStone I think.
Or you could simply google an online bmp to ico converter...
Oct 26, 2013 at 4:26pm
Are there any alternatives to this? Like system calls? I'm interested as well, because I'm wrapping winapi, but I don't want to have 13+ parameters just for the App Icon the Alt+Tab Icon and the Background??
Oct 26, 2013 at 4:46pm
Wait.. what?

The executable's main icon is automatically tied to everything that Windows shows you, including Alt-Tab and the like.

In other words, if your executable has a proper icon resource, then you don't need to worry about it anywhere else.
Oct 26, 2013 at 5:09pm
@Duoas

Wait.. what?

The executable's main icon is automatically tied to everything that Windows shows you, including Alt-Tab and the like.

In other words, if your executable has a proper icon resource, then you don't need to worry about it anywhere else.


I mean i have a wrapper where I accept an id to the icon resource as parameter to and
I don't want to have to pass a struct in just to create a window that has the HICONS that I want to be displayed at the top left/menu/etc. I would like to do it as a system call, as to avoid using/learning the .RC file format, or having to write .RC files everytime I make a new application.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
typedef
struct _possible_struct
{
   COLORREF background;
   COLORREF foreground;
   UINT appIdsmrc;
   UINT appIdrc;
   UINT appMenuIdrc;
}possible_struct;

//uses resource id's to link .ico file

bool RegClassEx_wrapperexample(WNDCLASSEX* pClassOut,...,
UINT Id_appIcon, UINT id_appIconAltTab, UINT id_menuresource, possible_struct* in );

//and I have a wrapper function that calls the above function

HWND MakeWindowEx_wrapperexample(const char* title, INT xpos, INT ypos,void* hProc, HINSTANCE hAppInstance,...,5-6 other params, possible_struct* in);
Last edited on Oct 26, 2013 at 5:15pm
Oct 26, 2013 at 6:03pm
do you mean like what you see when you want to click the exe? you need to make a resource file


Thank you so much guys!

Yes, How do I make one?
How do I make a resource file?

And, more importantly, how do I include it into a Visual Studio project?
what is the code that will "link" my .res file with my Windows.cpp code?

Thanks a lot in advance
Clodi
Oct 26, 2013 at 10:24pm
@DeXecipher
Creating a window really isn't that difficult a process. Further, you shouldn't have to care anything about resource files when you do -- just specify the resource ID of the icon -- which should be the same for every program (unless you want multiple icons and want to choose a different one than the default).

Which brings us back to ResHacker. Compile your app with the standard create my window with the default icon resource number. Use ResHacker to change the icon in your executable. Everything else falls in place for you.

Unless I completely misunderstand what you are trying to do,
Hope this helps.
Oct 27, 2013 at 4:52pm
what is ResHacker?
Oct 27, 2013 at 6:46pm
Duoas linked the program further up in the thread.
Topic archived. No new replies allowed.