how to create an icon?

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
closed account (Dy7SLyTq)
do you mean like what you see when you want to click the exe? you need to make a resource file
This little program is very friendly:
http://www.angusj.com/resourcehacker/
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...
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??
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.
@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
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
@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.
what is ResHacker?
Duoas linked the program further up in the thread.
Topic archived. No new replies allowed.