仅从Winforms顶部栏中删除图标,而不从任务栏中删除
本文关键字:删除 任务栏 图标 Winforms 仅从 顶部 | 更新日期: 2023-09-27 18:21:56
我有Winforms
应用程序,属性ShowIcon
和ShowInTaskbat
设置为true:
this.ShowIcon = true;
this.ShowInTaskbar = true;
目前,我可以在两个位置看到我的应用程序图标:
- 在任务栏上(我想成为)
- 在我的应用程序顶部(我想删除图标的地方)
如果我将属性ShowIcon
设置为false,我将无法在任务栏中看到该图标。是否可以仅从应用程序顶部栏中删除图标?
从项目属性窗体更改应用程序图标,然后它将出现在任务栏
尝试将FormBorderStyle
设置为FixedToolWindow
或SizableToolWindow
或您可以创建自己的自定义标题栏:http://customerborderform.codeplex.com/
如果关闭它,您需要将图标添加为资源并将其发送到您的窗口。
示例:
using System.Runtime.InteropServices;
..
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
struct IconHandler
{
internal const uint WmSeticon = 0x80u;
internal const int IconSmall = 0x0;
internal const int IconBig = 0x1;
}
public Main()
{
InitializeComponent();
//Properties.Resources.Icon.Handle is just an .*ico file in your resources. Icons can have different sizes.
SendMessage(Handle, IconHandler.WmSeticon, IconHandler.IconSmall, Properties.Resources.Icon.Handle);
SendMessage(Handle, IconHandler.WmSeticon, IconHandler.IconBig, Properties.Resources.Icon.Handle);
}