| Subject: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 12:38:52 AM |
| From: Juha Nieminen [Email Address Protection] |
I am using Visual C++ 2005 to create an application program, and I have a small problem properly adding an icon to it. I have created an .ico file (using the Gimp) which has 16x16, 32x32 and 48x48 versions of the icon, and for each a 4-bit, an 8-bit and a 32-bit version (in other words, 9 versions of the icon in total). I have added the .ico file as a resource in the project. The icon works perfectly when I view the application .exe file with Windows Explorer in all modes (the details view uses the 16x16 version, the icons view uses the 32x32 version, and the tiles view uses the 48x48 version). Also when I start the application, the 16x16 version correctly shows in the Windows task bar. However, the small icon on the upper left corner of the application window does *not* show any version of my icon. Instead, it shows the generic "application" icon (that which looks like an empty window). Also when I switch tasks with alt-tab, my application shows as that generic application icon instead of my own icon. Why is this, and how do I make it use my icon in those situations as well? I can't understand what I'm doing wrong. |
| Back |
| Subject: Re: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 3:41:23 AM |
| From: David Lowndes [Email Address Protection] |
> However, the small icon on the upper left corner of the application >window does *not* show any version of my icon. Instead, it shows the >generic "application" icon (that which looks like an empty window). Also >when I switch tasks with alt-tab, my application shows as that generic >application icon instead of my own icon. I think you need to use WM_SETICON. Dave |
| Back |
| Subject: Re: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 4:26:44 AM |
| From: Juha Nieminen [Email Address Protection] |
David Lowndes kirjoitti: >> However, the small icon on the upper left corner of the application >> window does *not* show any version of my icon. Instead, it shows the >> generic "application" icon (that which looks like an empty window). Also >> when I switch tasks with alt-tab, my application shows as that generic >> application icon instead of my own icon. > > I think you need to use WM_SETICON. Where and how exactly? (I have only added an icon to the resources of my VC++ project. I have not written any icon-related code anywhere. As I wrote, this works for everything else than the two cases above.) |
| Back |
| Subject: Re: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 4:39:39 AM |
| From: David Lowndes [Email Address Protection] |
>>> However, the small icon on the upper left corner of the application >>> window does *not* show any version of my icon. Instead, it shows the >>> generic "application" icon (that which looks like an empty window). Also >>> when I switch tasks with alt-tab, my application shows as that generic >>> application icon instead of my own icon. >> >> I think you need to use WM_SETICON. > > Where and how exactly? In your application's initialisation, use SendMessage 2x (1 large, 1 small) with your icon to your top level frame window. Dave |
| Back |
| Subject: Re: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 7:08:43 AM |
| From: "Scott Seligman" [Email Address Protection] |
Juha Nieminen <nospam@thanks.invalid> wrote: > > I am using Visual C++ 2005 >to create an application >program, and I >have a small problem properly >adding an icon to it. > > I have created an .ico >file (using the Gimp) which >has 16x16, 32x32 >and 48x48 versions of the >icon, and for each a 4-bit, >an 8-bit and a >32-bit version (in other >words, 9 versions of the icon >in total). I have >added the .ico file as a >resource in the project. > > The icon works perfectly >when I view the application >.exe file with >Windows Explorer in all modes >(the details view uses the >16x16 version, >the icons view uses the 32x32 >version, and the tiles view >uses the 48x48 >version). Also when I start >the application, the 16x16 >version correctly >shows in the Windows task bar. > > However, the small icon on >the upper left corner of the >application >window does *not* show any >version of my icon. Instead, >it shows the >generic "application" icon >(that which looks like an >empty window). Also >when I switch tasks with >alt-tab, my application shows >as that generic >application icon instead of >my own icon. > > Why is this, and how do I >make it use my icon in those >situations as >well? I can't understand what >I'm doing wrong. -- --------- Scott Seligman <scott at <firstname> and michelle dot net> --------- Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway. -- Andrew S. Tanenbaum |
| Back |
| Subject: Re: Adding an icon to a Visual C++ executable |
| Group: microsoft.public.vstudio.general |
| Date: 9/4/2008 7:44:37 AM |
| From: "Scott Seligman" [Email Address Protection] |
Juha Nieminen <nospam@thanks.invalid> wrote: > > However, the small icon on the upper left corner of the application >window does *not* show any version of my icon. Instead, it shows the >generic "application" icon (that which looks like an empty window). Also >when I switch tasks with alt-tab, my application shows as that generic >application icon instead of my own icon. > > Why is this, and how do I make it use my icon in those situations as >well? I can't understand what I'm doing wrong. Add the icon to the appropriate members of the WNDCLASSEX structure for your RegisterClassEx call: wcex.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_ICONNAME)); wcex.hIconSm = (HICON) LoadImage(m_hInstance, MAKEINTRESOURCE(IDI_ICONNAME), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); -- --------- Scott Seligman <scott at <firstname> and michelle dot net> --------- The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...' -- Isaac Asimov |
| Back |