How to set the program icon

Started by
3 comments, last by Arcibald Wearlot 20 years, 5 months ago
thats the question - how do i set the program icon in ms visual c++ 6.0. i tried to include it as a resource but it didnt work. i mean i want to set it as the executable icon, instead of the standard one. i found nothing useful on msdn or google.. funny isn''t it? i''m writing a 3d engine and lots of hard stuff and i still can''t figure out how to set an icon -_-
Advertisement
Including it as a resource should be sufficient - I''m pretty sure windows just picks the first icon resource it can find in the executable as the program icon.

You might need to make it a numbered resource rather than a named resource, (not sure though) and you''d also need to make sure that it fits the requirements for a windows icon, but other than that, I can''t see any reason why it shouldn''t work.

Another thing you could do if you haven''t already is do a full rebuild. MSVC is sometimes a bit lazy with updating the resources.
http://www.winprog.org/tutorial/menus.html

quote:Windows Explorer simply displays the first icon (numerically by ID) in the program files resources, so since we only have one icon, that''s what it is displaying. If you want to be sure that a certain icon is displayed with your program file, simply add it as a resource and assign it a very low ID... like 1.
Generally the name of the icon it uses for its executable icon is IDR_MAINFRAME, though ordering your icon manually before IDR_MAINFRAME in Resource.h would work. Just make sure that when you're reordering it manually that you don't overwrite somebody else's ID. I've always just replaced the IDR_MAINFRAME and it's done fine, with a gotcha...

Your executable has several different "types" of icons it uses, dependent on whether you're looking at a full icon (32x32) on the desktop or in an icon list, or at the little bitty icon for a files detail list and the upper left corner, etc. In order to change that you need to change the different styles of icons (if you've replaced IDR_MAINFRAME by copying over it) or make a few styles of icons if it doesn't shrink it properly for you. To do that in 6.0, with your icon on the screen, go to Image->Open Device Image. You will need to modify all 3 icon sizes of the type you're using (you can tell by screen resolution which colorset is correct) in order to cover "all" cases. To make it easier, you might try selecting various types you're not using from the "Device" combo at the top of your work area, and choosing Image->Delete Device Image.

It would also work if you deleted the IDR_MAINFRAME and had your desired icon as the only available icon on the list.

-fel


[edited by - felisandria on November 13, 2003 10:11:40 AM]
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
i rebuilt all and now it works, thank you guys

This topic is closed to new replies.

Advertisement