SystemPens 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
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 表單。 建立一個包含 Button 名稱 subtractButton的表單。 將程式碼貼入表單,並從表單的CreatePointsAndSizes事件處理方法呼叫該Paint方法,傳遞e為 PaintEventArgs。
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
備註
Note
在 .NET 6 和更新版本中,只有 Windows作系統才支援包含此類型的 System.Drawing.Common 套件。 跨平台應用程式使用此類會引發編譯時警告及執行時異常。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common。
屬性
| 名稱 | Description |
|---|---|
| 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 |
取得 a 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 一個視窗客戶端區域文字顏色的顯示。 |
方法
| 名稱 | Description |
|---|---|
| FromSystemColor(Color) |