SystemIcons 類別

定義

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

範例

下列程式碼範例示範如何使用 列舉從控制碼 GraphicsUnit 載入點陣圖 Icon ,以及使用 Round 方法來繪製點陣圖的矩形界限。

此範例的設計目的是要與Windows Forms搭配使用。 建立表單,其中包含名為 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 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時間警告和執行時間例外狀況。 如需詳細資訊,請參閱 僅限 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 殼層庫存圖示。

GetStockIcon(StockIconId, StockIconOptions)

取得指定的 Windows 殼層庫存圖示。

適用於