I have both dark and light versions of my application icon; the dark version works best on gray surfaces such as Windows XP taskbar, where the light version works best as an icon in the titlebar.
Is there a way I can set the icon in the taskbar to a different icon than the one used in my form in C# (P/Invoke is fine)?
Alternatively, if you hold Shift and right-click the icon on the taskbar, you get the standard Windows Explorer context menu, instead of the application jump list. Again, click Properties. From the Properties dialog, go to the Shortcut tab and click the Change Icon button. Select a new icon file by clicking Browse.
If you want to manage and customize the Taskbar icons, just right-click on the Taskbar, select Settings, then under Multiple displays, look for Combine buttons on the taskbars, and select Never on the drop-down menu. This will change the Taskbar icons to your preferred Taskbar view.
Click on Start > Settings Personalization > Taskbar. Scroll down to Combine taskbar buttons. Click on Never. If you click on When taskbar is full, then application names will only appear as long as they fit into your taskbar.
Send the WM_SETICON message to your form with different icon handles for the ICON_SMALL and the ICON_BIG parameter:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
private const uint WM_SETICON = 0x80u;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
public MyForm()
{
InitializeComponent();
SendMessage(this.Handle, WM_SETICON, ICON_SMALL, Properties.Resources.IconSmall.Handle);
SendMessage(this.Handle, WM_SETICON, ICON_BIG, Properties.Resources.IconBig.Handle);
}
I know this is an old question but I came across it when trying to achieve the same thing, and well yes you can do this, on Windows 7/8 at least.
It turns out an ICO file doesn't just contain one image, it contains 9 different images at 9 different resolutions:
On Windows 7 and 8, the 64x64 image is used on the taskbar, and the 16x16 image is used on the icon which is placed on the top left hand corner of your form.
You can use a tool like Greenfish Icon Editor Pro (I don't work for them or anything, this isn't a plug!) to have these as two seperate images, and then add this *.ico
file as normal to your Windows Form/WPF form in Visual Studio.
The end result is shown below:
As you can see my WPF application has two seperate icons, one in the taskbar and another on the form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With