SystemIcons 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
SystemIcons 类的每个属性都是Windows系统范围的图标的 Icon 对象。 此类不能被继承。
public ref class SystemIcons abstract sealed
public ref class SystemIcons sealed
public static class SystemIcons
public sealed class SystemIcons
type SystemIcons = class
Public Class SystemIcons
Public NotInheritable Class SystemIcons
- 继承
-
SystemIcons
示例
下面的代码示例演示如何使用Icon枚举从句柄加载位图GraphicsUnit,以及如何使用Round该方法绘制位图的矩形边界。
此示例旨在与 Windows 窗体一起使用。 创建包含名为 Button2 的按钮的窗体。 将代码粘贴到窗体中,并将此方法与按钮 Click 的事件相关联。
void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Bitmap^ bitmap1 = Bitmap::FromHicon( SystemIcons::Hand->Handle );
Graphics^ formGraphics = this->CreateGraphics();
GraphicsUnit units = GraphicsUnit::Point;
RectangleF bmpRectangleF = bitmap1->GetBounds( units );
Rectangle bmpRectangle = Rectangle::Round( bmpRectangleF );
formGraphics->DrawRectangle( Pens::Blue, bmpRectangle );
delete formGraphics;
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{
Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Hand.Handle);
Graphics formGraphics = this.CreateGraphics();
GraphicsUnit units = GraphicsUnit.Point;
RectangleF bmpRectangleF = bitmap1.GetBounds(ref units);
Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);
formGraphics.DrawRectangle(Pens.Blue, bmpRectangle);
formGraphics.Dispose();
}
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim bitmap1 As Bitmap = Bitmap.FromHicon(SystemIcons.Hand.Handle)
Dim formGraphics As Graphics = Me.CreateGraphics()
Dim units As GraphicsUnit = GraphicsUnit.Point
Dim bmpRectangleF As RectangleF = bitmap1.GetBounds(units)
Dim bmpRectangle As Rectangle = Rectangle.Round(bmpRectangleF)
formGraphics.DrawRectangle(Pens.Blue, bmpRectangle)
formGraphics.Dispose()
End Sub
注解
注释
在 .NET 6 及更高版本中,包含此类型的 System.Drawing.Common 包 仅支持在 Windows 操作系统上运行。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 仅在 Windows 上支持的 System.Drawing.Common。
属性
| 名称 | 说明 |
|---|---|
| Application |
获取一个 Icon 对象,该对象包含默认应用程序图标(WIN32:IDI_APPLICATION)。 |
| Asterisk |
获取一个 Icon 对象,该对象包含系统星号图标(WIN32:IDI_ASTERISK)。 |
| Error |
获取一个 Icon 对象,该对象包含系统错误图标(WIN32:IDI_ERROR)。 |
| Exclamation |
获取一个 Icon 对象,该对象包含系统感叹号图标(WIN32:IDI_EXCLAMATION)。 |
| Hand |
获取一个 Icon 对象,该对象包含系统手形图标(WIN32:IDI_HAND)。 |
| Information |
获取一个 Icon 对象,该对象包含系统信息图标(WIN32:IDI_INFORMATION)。 |
| Question |
获取一个 Icon 对象,该对象包含系统问题图标(WIN32:IDI_QUESTION)。 |
| Shield |
Icon获取包含盾牌图标的对象。 |
| Warning |
获取一个 Icon 对象,该对象包含系统警告图标(WIN32:IDI_WARNING)。 |
| WinLogo |
获取一个Icon对象,该对象包含Windows徽标图标(WIN32:IDI_WINLOGO)。 |
方法
| 名称 | 说明 |
|---|---|
| GetStockIcon(StockIconId, Int32) |
获取指定的Windows shell 库存图标。 |
| GetStockIcon(StockIconId, StockIconOptions) |
获取指定的Windows shell 库存图标。 |