SystemPens 類別

定義

SystemPens 類別的每個屬性都是 Pen,其為 Windows 顯示項目的色彩,並且寬度為 1 像素。

public ref class SystemPens abstract sealed
public ref class SystemPens sealed
public static class SystemPens
public sealed class SystemPens
type SystemPens = class
Public Class SystemPens
Public NotInheritable Class SystemPens
繼承
SystemPens

範例

下列程式代碼範例會使用針對這些類型定義的數個多載運算符來建立點和大小。 它也會示範如何使用 SystemPens 類別。

此範例的設計目的是要與 Windows Forms 搭配使用。 Create 包含具名 subtractButtonButton表單。 將程式代碼貼到表單中,並從表單的事件Paint處理方法呼叫 CreatePointsAndSizes 方法,並傳遞ePaintEventArgs

void CreatePointsAndSizes( PaintEventArgs^ e )
{
   // Create the starting point.
   Point startPoint = Point(subtractButton->Size);
   
   // Use the addition operator to get the end point.
   Point endPoint = startPoint + System::Drawing::Size( 140, 150 );
   
   // Draw a line between the points.
   e->Graphics->DrawLine( SystemPens::Highlight, startPoint, endPoint );
   
   // Convert the starting point to a size and compare it to the
   // subtractButton size.  
   System::Drawing::Size buttonSize = (System::Drawing::Size)startPoint;
   if ( buttonSize == subtractButton->Size )
   {
      e->Graphics->DrawString( "The sizes are equal.", gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), Brushes::Indigo, 10.0F, 65.0F );
   }
}
private void CreatePointsAndSizes(PaintEventArgs e)
{

    // Create the starting point.
    Point startPoint = new Point(subtractButton.Size);

    // Use the addition operator to get the end point.
    Point endPoint = startPoint + new Size(140, 150);

    // Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint);

    // Convert the starting point to a size and compare it to the
    // subtractButton size.  
    Size buttonSize = (Size)startPoint;
    if (buttonSize == subtractButton.Size)

        // If the sizes are equal, tell the user.
    {
        e.Graphics.DrawString("The sizes are equal.", 
            new Font(this.Font, FontStyle.Italic), 
            Brushes.Indigo, 10.0F, 65.0F);
    }
}
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)

    ' Create the starting point.
    Dim startPoint As New Point(subtractButton.Size)

    ' Use the addition operator to get the end point.
    Dim endPoint As Point = Point.op_Addition(startPoint, _
        New Size(140, 150))

    ' Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)

    ' Convert the starting point to a size and compare it to the
    ' subtractButton size.  
    Dim buttonSize As Size = Point.op_Explicit(startPoint)
    If (Size.op_Equality(buttonSize, subtractButton.Size)) Then

        ' If the sizes are equal, tell the user.
        e.Graphics.DrawString("The sizes are equal.", _
            New Font(Me.Font, FontStyle.Italic), _
            Brushes.Indigo, 10.0F, 65.0F)
    End If

End Sub

備註

注意

在 .NET 6 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時間警告和運行時間例外狀況。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common

屬性

ActiveBorder

取得 Pen,這是使用中視窗框線的色彩。

ActiveCaption

取得 Pen,其為使用中視窗標題列的背景色彩。

ActiveCaptionText

取得 Pen,這是使用中視窗標題列之文字的色彩。

AppWorkspace

取得 Pen,這是應用程式工作區的色彩。

ButtonFace

取得 Pen,其為 3D 項目的表面色彩。

ButtonHighlight

取得 Pen,其為 3D 項目的醒目提示色彩。

ButtonShadow

取得 Pen,其為 3D 項目的陰影色彩。

Control

取得 Pen,其為 3D 項目的表面色彩。

ControlDark

取得 Pen,其為 3D 項目的陰影色彩。

ControlDarkDark

取得 Pen,其為 3D 項目的深色陰影色彩。

ControlLight

取得 Pen,其為 3D 項目的淺色色彩。

ControlLightLight

取得 Pen,其為 3D 項目的醒目提示色彩。

ControlText

取得 Pen,其為 3D 項目中文字的色彩。

Desktop

取得 Pen,其為 Windows 桌面的色彩。

GradientActiveCaption

取得 Pen,其為使用中視窗標題列之色彩漸層中最亮的色彩。

GradientInactiveCaption

取得 Pen,其為非使用中視窗標題列之色彩漸層中最亮的色彩。

GrayText

取得 Pen,其為暗灰色文字的色彩。

Highlight

取得 Pen,其為選取之項目的背景色彩。

HighlightText

取得 Pen,也就是所選項目的文字色彩。

HotTrack

取得 Pen,這是用來指定熱點追蹤項目的色彩。

InactiveBorder

取得 Pen,其為非使用中視窗的框線色彩。

InactiveCaption

取得 Pen,其為非使用中視窗之標題列標題的色彩。

InactiveCaptionText

取得 Pen,其為非使用中視窗標題列的文字色彩。

Info

取得 Pen,其為工具提示的背景色彩。

InfoText

取得 Pen,其為工具提示的文字色彩。

Menu

取得表示功能表背景色彩的 Pen

MenuBar

取得 Pen,其為功能表列的背景色彩。

MenuHighlight

取得 Pen,其為用來在功能表顯示為平面功能表時反白顯示功能表項目的色彩。

MenuText

取得表示功能表文字色彩的 Pen

ScrollBar

取得 Pen,其為捲軸的背景色彩。

Window

取得 Pen,其為視窗工作區中背景的色彩。

WindowFrame

取得 Pen,其為視窗框架的色彩。

WindowText

取得 Pen,其為視窗工作區中 (client area) 文字的色彩。

方法

FromSystemColor(Color)

從指定的 Pen 建立 Color

適用於