且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#,.NET中叠加图标

更新时间:2023-02-08 19:27:51

在.NET中创建shell覆盖图标时看到这个:



.NET Shell扩展程序 - 外壳图标叠加代表 [ ^ ]
See this for creating shell overlay icons in .NET:

.NET Shell Extensions - Shell Icon Overlay Handers[^]


您不需要图标。图标是特殊的多页面资源,在同一文件中包含不同分辨率的图像,通常为16x16和32x32。这是与Windows和Shell协作所必需的。在应用程序中,图标仅用作应用程序图标(因此应用程序在系统托盘和文件管理器/对话框中正确显示)和窗口图标。使用图标,OS选择适当分辨率的图像。如果您在其他任何地方使用图标,其属性将是多余的。从技术上讲,你可以使用它们,但没有理由这样做。



对于所有其他情况,应该使用位图。图标也支持透明色,但如果将它们存储为PNG,位图也是如此。



叠加它们没有问题。您可以使用 System.Drawing.Graphics.DrawImage System.Windows.Forms.PictureBox 在控件渲染中使用位图。



-SA
You don''t need icons. Icons are special multi-page resources which contain images of different resolution in the same file, typically 16x16 and 32x32. This is needed for collaboration with Windows and Shell. In applications, icons are only uses as application icons (so the application is shown correctly in the system tray and file managers/dialogs) and windows icons. With icons, OS selects the image of appropriate resolution. If you use icons anywhere else, their properties would be redundant. Technically, you can use them, but there is not reason for doing that.

For all other cases, bitmaps should be used. Icons also support transparent colors, but so do bitmaps if you store them as PNG.

There is no problem of overlay them. You can use bitmaps in control rendering using System.Drawing.Graphics.DrawImage or System.Windows.Forms.PictureBox.

—SA


Hope 如何通过3个简单的步骤将图标覆盖在现有的shell对象上 [ ^ ]来自CP的文章可能对您有所帮助。
Hope How to overlay an icon over existing shell objects in 3 easy steps[^] an article from CP might help you.