设置不同的任务栏图标的标题栏(C#)显示的图标? [英] Setting a different taskbar icon to the icon displayed in the titlebar (C#)?
本文介绍了设置不同的任务栏图标的标题栏(C#)显示的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的应用程序图标的两个深色和浅色版本;黑暗版本的作品最好的灰色表面,如Windows XP任务栏,那里的轻型版本最适合作为标题栏中显示的图标。
有没有一种方法,我可以设置在任务栏比在C#在我的表单中使用的(P / Invoke的是罚款)?
解决方案
不同的图标图标发送WM_SETICON消息以不同的图标表单处理的ICON_SMALL和ICON_BIG参数:
<预类=郎-CS prettyprint-覆盖>
函数[DllImport(user32.dll中,字符集= CharSet.Auto)]
静态外部的IntPtr SendMessage函数(IntPtr的的HWND,UINT消息,诠释的wParam,lParam的的IntPtr);
私人常量UINT WM_SETICON = 0x80u;
私人const int的ICON_SMALL = 0;
私人const int的ICON_BIG = 1;
公共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 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)?
解决方案
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);
}
这篇关于设置不同的任务栏图标的标题栏(C#)显示的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文