我的应用程序图标有深色和浅色版本;深色版本在 Windows XP 任务栏等灰色表面上效果最佳,而浅色版本在标题栏中作为图标效果最佳。
有没有一种方法可以将任务栏中的图标设置为与我在 C# 中的表单中使用的图标不同的图标(P/Invoke 可以)?
最佳答案
使用 ICON_SMALL 和 ICON_BIG 参数的不同图标句柄将 WM_SETICON 消息发送到您的表单:
[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# - 将不同的任务栏图标设置为标题栏 (C#) 中显示的图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4048910/