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

範例

以下程式碼範例示範如何利用IconGraphicsUnit枚舉從handle載入位圖,並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

備註

Note

在 .NET 6 和更新版本中,只有 Windows作系統才支援包含此類型的 System.Drawing.Common 套件。 跨平台應用程式使用此類會引發編譯時警告及執行時異常。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common。

屬性

名稱 Description
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

會取得一個包含 Windows 標誌圖示的 Icon 物件(WIN32:IDI_WINLOGO)。

方法

名稱 Description
GetStockIcon(StockIconId, Int32)

會得到指定的 Windows 殼原廠圖示。

GetStockIcon(StockIconId, StockIconOptions)

會得到指定的 Windows 殼原廠圖示。

適用於

另請參閱