I searched around a bit, and all I could find was stuff about changing the icon of the EXE or using icons built into the EXE with a resource file. However, this is not what I want to do. I want to, given a file path, at runtime change the icon of the application. I have a variable that i think controls the icon of the window, and it seems to be of type HICON. I know this is possible because I see programs like windows explorer do it all the time. So what code and includes do I need to do this?
Er, he wants to modify the resources in another executable.
That isn't as simple as it looks at first blush. You might as well employ another application/library to do it. I use Resource Hacker. http://www.angusj.com/resourcehacker/
Hope this helps.
There are two icons in the window, 32x32 and 16x16. If you want to change the the icon at the task bar and title bar you should do hIconSm = (HICON)LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
LoadImage just loads the icon from the file. You need to assign the icon to the window. You do this by sending a WM_SETICON message:
1 2 3
SendMessage( yourwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon );
// you can also use ICON_BIG instead of ICON_SMALL to set the big icon.
// exactly what the difference is, I'm not sure
Also, I found out the difference with the ICON_SMALL and ICON_BIG, if you only set ICON_SMALL then the Alt-Tab icon is stretched and looks bad. If you set the ICON_BIG as well as ICON_SMALL, then everything looks nice.