SystemIcons 类

SystemIcons 类的每个属性都是 Windows 系统级图标的 Icon 对象。无法继承此类。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public NotInheritable Class SystemIcons
用法
Dim instance As SystemIcons
public sealed class SystemIcons
public ref class SystemIcons sealed
public final class SystemIcons
public final class SystemIcons

示例

下面的代码示例演示如何使用 GraphicsUnit 枚举,从 Icon 句柄加载位图,以及如何使用 Round 方法绘制位图的矩形边框。

此示例是针对使用 Windows 窗体而设计的。创建一个包含名为 Button2 的按钮的窗体。将代码粘贴到该窗体中,并将此方法与按钮的 Click 事件相关联。

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
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();
}
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.get_Hand().get_Handle());
    Graphics formGraphics = this.CreateGraphics();
    GraphicsUnit units = GraphicsUnit.Point;
    RectangleF bmpRectangleF = bitmap1.GetBounds(units);
    Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);

    formGraphics.DrawRectangle(Pens.get_Blue(), bmpRectangle);
    formGraphics.Dispose();
} //button2_Click

继承层次结构

System.Object
  System.Drawing.SystemIcons

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

SystemIcons 成员
System.Drawing 命名空间