我有一个 .ico 文件,其中嵌入了 5 种图标大小,用作主应用程序图标和系统托盘图标。
当它出现在任务栏中时,图标使用的是所需的 16x16 格式。 当图标出现在通知区域/系统托盘中时,它使用的是 32x32 格式,而 Windows 将其渲染为 16x16 图标,这看起来很糟糕。
如何强制 Windows 在通知区域使用 16x16 图标大小? 这是我将图标放入系统托盘的代码:
ContextMenu cmNotify = new ContextMenu();
MenuItem miNotify = new MenuItem(Properties.Resources.Notify_Text);
miNotify.DefaultItem = true;
miNotify.Click += new EventHandler(notifyHandler);
cmNotify.MenuItems.Add(miNotify);
notifyIcon = new NotifyIcon();
notifyIcon.Icon = this.Icon;
notifyIcon.Visible = true;
notifyIcon.ContextMenu = cmNotify;
notifyIcon.Text = AppConstants.APPLICATION_NAME;
最佳答案
两种 react 都很接近,但都含有微妙的毒药。您不应将请求的大小硬编码为 16x16。
相反,查询 SystemInformation.SmallIconSize 以确定适当的尺寸。虽然默认值肯定是 16x16,但这可以通过各种方式更改,例如 DPI 缩放。
参见 the MSDN article有关此属性的更多信息。
一个用法的例子是
notifyIcon.Icon = new System.Drawing.Icon(this.Icon, SystemInformation.SmallIconSize),
关于.net - Windows 从多图标文件中选择了错误的图标并自行呈现为正确的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/616500/