SystemPens 类

定义

SystemPens 类的每个属性都是一个 Pen,它是 Windows 显示元素的颜色,宽度为 1 个像素。Each property of the SystemPens class is a Pen that is the color of a Windows display element and that has a width of 1 pixel.

public ref class SystemPens sealed
public sealed class SystemPens
type SystemPens = class
Public NotInheritable Class SystemPens
继承
SystemPens

示例

下面的代码示例使用为这些类型定义的多个重载运算符来创建点和大小。The following code example creates points and sizes using several of the overloaded operators defined for these types. 它还演示了如何使用SystemPens类。It also demonstrates how to use the SystemPens class.

此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 创建一个包含Button名为subtractButton的窗体。Create a form that contains a Button named subtractButton. 将代码粘贴到窗体中, 并CreatePointsAndSizes从窗体的Paint事件处理方法中调用方法, ePaintEventArgs将作为传递。Paste the code into the form and call the CreatePointsAndSizes method from the form's Paint event-handling method, passing e as 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

属性

ActiveBorder

获取作为活动窗口边框的颜色的 PenGets a Pen that is the color of the active window's border.

ActiveCaption

获取表示活动窗口标题栏背景颜色的 PenGets a Pen that is the color of the background of the active window's title bar.

ActiveCaptionText

获取 Pen,它是活动窗口标题栏中文本的颜色。Gets a Pen that is the color of the text in the active window's title bar.

AppWorkspace

获取表示应用程序工作区的颜色的 PenGets a Pen that is the color of the application workspace.

ButtonFace

获取表示三维元素表面颜色的 PenGets a Pen that is the face color of a 3-D element.

ButtonHighlight

获取表示三维元素突出显示颜色的 PenGets a Pen that is the highlight color of a 3-D element.

ButtonShadow

获取表示三维元素阴影颜色的 PenGets a Pen that is the shadow color of a 3-D element.

Control

获取表示三维元素表面颜色的 PenGets a Pen that is the face color of a 3-D element.

ControlDark

获取表示三维元素阴影颜色的 PenGets a Pen that is the shadow color of a 3-D element.

ControlDarkDark

获取表示三维元素暗阴影颜色的 PenGets a Pen that is the dark shadow color of a 3-D element.

ControlLight

获取表示三维元素亮色的 PenGets a Pen that is the light color of a 3-D element.

ControlLightLight

获取表示三维元素突出显示颜色的 PenGets a Pen that is the highlight color of a 3-D element.

ControlText

获取表示三维元素中文本颜色的 PenGets a Pen that is the color of text in a 3-D element.

Desktop

获取表示 Windows 桌面颜色的 PenGets a Pen that is the color of the Windows desktop.

GradientActiveCaption

获取表示活动窗口标题栏的颜色渐变中最亮的颜色的 PenGets a Pen that is the lightest color in the color gradient of an active window's title bar.

GradientInactiveCaption

获取表示非活动窗口标题栏的颜色渐变中最亮的颜色的 PenGets a Pen that is the lightest color in the color gradient of an inactive window's title bar.

GrayText

获取表示禁用文本的颜色的 PenGets a Pen that is the color of dimmed text.

Highlight

获取表示选定项背景颜色的 PenGets a Pen that is the color of the background of selected items.

HighlightText

获取一个 Pen 结构,它为选定项的文本颜色。Gets a Pen that is the color of the text of selected items.

HotTrack

获取 Pen,它是用于指定热跟踪项的颜色。Gets a Pen that is the color used to designate a hot-tracked item.

InactiveBorder

获取表示非活动窗口边框颜色的 PenGets a Pen is the color of the border of an inactive window.

InactiveCaption

获取表示非活动窗口标题栏标题颜色的 PenGets a Pen that is the color of the title bar caption of an inactive window.

InactiveCaptionText

获取表示非活动窗口标题栏中文本颜色的 PenGets a Pen that is the color of the text in an inactive window's title bar.

Info

获取表示工具提示的背景颜色的 PenGets a Pen that is the color of the background of a ToolTip.

InfoText

获取表示工具提示的文本颜色的 PenGets a Pen that is the color of the text of a ToolTip.

Menu

获取表示菜单背景颜色的 PenGets a Pen that is the color of a menu's background.

MenuBar

获取表示菜单栏背景颜色的 PenGets a Pen that is the color of the background of a menu bar.

MenuHighlight

获取表示当菜单显示为平面菜单时用于突出显示菜单项的颜色的 PenGets a Pen that is the color used to highlight menu items when the menu appears as a flat menu.

MenuText

获取表示菜单文本颜色的 PenGets a Pen that is the color of a menu's text.

ScrollBar

获取表示滚动条背景颜色的 PenGets a Pen that is the color of the background of a scroll bar.

Window

获取表示窗口工作区中背景颜色的 PenGets a Pen that is the color of the background in the client area of a window.

WindowFrame

获取表示窗口框架颜色的 PenGets a Pen that is the color of a window frame.

WindowText

获取表示窗口工作区中文本颜色的 PenGets a Pen that is the color of the text in the client area of a window.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FromSystemColor(Color)

从指定的 Pen 创建 ColorCreates a Pen from the specified Color.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于