将不同的任务栏图标设置为标题栏中显示的图标(C#)?
我的应用程序图标有深色和浅色版本;深色版本在灰色表面(例如 Windows XP 任务栏)上效果最佳,浅色版本在标题栏中作为图标效果最佳。
有没有一种方法可以将任务栏中的图标设置为与 C# 表单中使用的图标不同的图标(P/Invoke 就可以)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ICON_SMALL 和 ICON_BIG 参数的不同图标句柄将 WM_SETICON 消息发送到表单:
Send the WM_SETICON message to your form with different icon handles for the ICON_SMALL and the ICON_BIG parameter:
我知道这是一个老问题,但我在尝试实现同样的目标时遇到了它,是的,你可以做到这一点,至少在 Windows 7/8 上。
事实证明,ICO 文件不仅仅包含一张图像,它还包含 9 种不同分辨率的 9 个不同图像:
在 Windows 7 和 8 上,64x64 图像用于任务栏,而16x16 图像用于位于表单左上角的图标。
您可以使用 Greenfish Icon Editor Pro 之类的工具(我不为他们工作,或者任何东西,这不是插件!)将它们作为两个单独的图像,然后将此
*.ico
文件正常添加到 Visual Studio 中的 Windows 窗体/WPF 窗体中。最终结果如下所示:
如您所见,我的 WPF 应用程序有两个单独的图标,一个在任务栏中,另一个在任务栏中表格上。
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.