语言

ControlPaint.DrawCaptionButton 方法

定义

绘制标题按钮控件。

重载

名称 说明
DrawCaptionButton(Graphics, Rectangle, CaptionButton, ButtonState)

在指定的图形图面和指定边界内绘制处于指定状态的指定标题按钮控件。

DrawCaptionButton(Graphics, Int32, Int32, Int32, Int32, CaptionButton, ButtonState)

在指定的图形图面和指定边界内绘制处于指定状态的指定标题按钮控件。

DrawCaptionButton(Graphics, Rectangle, CaptionButton, ButtonState)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

在指定的图形图面和指定边界内绘制处于指定状态的指定标题按钮控件。

public:
 static void DrawCaptionButton(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle rectangle, System::Windows::Forms::CaptionButton button, System::Windows::Forms::ButtonState state);
public static void DrawCaptionButton(System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Windows.Forms.CaptionButton button, System.Windows.Forms.ButtonState state);
static member DrawCaptionButton : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.CaptionButton * System.Windows.Forms.ButtonState -> unit
Public Shared Sub DrawCaptionButton (graphics As Graphics, rectangle As Rectangle, button As CaptionButton, state As ButtonState)

参数

graphics
Graphics

要 Graphics 绘制的。

rectangle
Rectangle

表示 Rectangle 标题按钮的尺寸。

button
CaptionButton

指定要 CaptionButton 绘制的标题按钮类型的值之一。

state
ButtonState

指定要在其中绘制按钮的状态的值的 ButtonState 按位组合。

示例

下面的代码示例演示如何使用 ControlPaint.DrawCaptionButton 方法和 CaptionButton 枚举。 若要运行此示例,请将以下代码粘贴到包含名为 Button1Button 的窗体中。 窗体应导入 System.Windows.Forms 和 System.Drawing 命名空间。 确保按钮的事件与此示例中的 Paint 事件处理程序相关联。

// Handle the Button1 object's Paint Event to create a CaptionButton.
void Button1_Paint( Object^ /*sender*/, PaintEventArgs^ e )
{
   
   // Draw a CaptionButton control using the ClientRectangle 
   // property of Button1. Make the button a Help button 
   // with a normal state.
   ControlPaint::DrawCaptionButton( e->Graphics, Button1->ClientRectangle, CaptionButton::Help, ButtonState::Normal );
}
// Handle the Button1 object's Paint Event to create a CaptionButton.
private void Button1_Paint(object sender, PaintEventArgs e)
{

    // Draw a CaptionButton control using the ClientRectangle 
    // property of Button1. Make the button a Help button 
    // with a normal state.
    ControlPaint.DrawCaptionButton(e.Graphics, Button1.ClientRectangle,
        CaptionButton.Help, ButtonState.Normal);
}
' Handle the Button1 object's Paint Event to create a CaptionButton.
Private Sub Button1_Paint(ByVal sender As Object, _
    ByVal e As PaintEventArgs) Handles Button1.Paint

    ' Draw a CaptionButton control using the ClientRectangle 
    ' property of Button1. Make the button a Help button 
    ' with a normal state.
    ControlPaint.DrawCaptionButton(e.Graphics, Button1.ClientRectangle, _
        CaptionButton.Help, ButtonState.Normal)
End Sub

另请参阅

适用于

DrawCaptionButton(Graphics, Int32, Int32, Int32, Int32, CaptionButton, ButtonState)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

在指定的图形图面和指定边界内绘制处于指定状态的指定标题按钮控件。

public:
 static void DrawCaptionButton(System::Drawing::Graphics ^ graphics, int x, int y, int width, int height, System::Windows::Forms::CaptionButton button, System::Windows::Forms::ButtonState state);
public static void DrawCaptionButton(System.Drawing.Graphics graphics, int x, int y, int width, int height, System.Windows.Forms.CaptionButton button, System.Windows.Forms.ButtonState state);
static member DrawCaptionButton : System.Drawing.Graphics * int * int * int * int * System.Windows.Forms.CaptionButton * System.Windows.Forms.ButtonState -> unit
Public Shared Sub DrawCaptionButton (graphics As Graphics, x As Integer, y As Integer, width As Integer, height As Integer, button As CaptionButton, state As ButtonState)

参数

graphics
Graphics

要 Graphics 绘制的。

x
Int32

绘图矩形左上角的 x 坐标。

y
Int32

绘图矩形左上角的 y 坐标。

width
Int32

绘图矩形的宽度。

height
Int32

绘图矩形的高度。

button
CaptionButton

指定要 CaptionButton 绘制的标题按钮类型的值之一。

state
ButtonState

指定要在其中绘制按钮的状态的值的 ButtonState 按位组合。

示例

下面的代码示例演示如何使用 DrawCaptionButton 方法和 CaptionButton 枚举。 若要运行此示例,请将以下代码粘贴到包含命名的ButtonButton1表单中。 窗体应导入 System.Windows.Forms 和 System.Drawing 命名空间。 确保按钮的事件与此示例中的 Paint 事件处理程序相关联。

// Handle the Button1 object's Paint Event to create a CaptionButton.
void Button1_Paint( Object^ /*sender*/, PaintEventArgs^ e )
{
   
   // Draw a CaptionButton control using the ClientRectangle 
   // property of Button1. Make the button a Help button 
   // with a normal state.
   ControlPaint::DrawCaptionButton( e->Graphics, Button1->ClientRectangle, CaptionButton::Help, ButtonState::Normal );
}
// Handle the Button1 object's Paint Event to create a CaptionButton.
private void Button1_Paint(object sender, PaintEventArgs e)
{

    // Draw a CaptionButton control using the ClientRectangle 
    // property of Button1. Make the button a Help button 
    // with a normal state.
    ControlPaint.DrawCaptionButton(e.Graphics, Button1.ClientRectangle,
        CaptionButton.Help, ButtonState.Normal);
}
' Handle the Button1 object's Paint Event to create a CaptionButton.
Private Sub Button1_Paint(ByVal sender As Object, _
    ByVal e As PaintEventArgs) Handles Button1.Paint

    ' Draw a CaptionButton control using the ClientRectangle 
    ' property of Button1. Make the button a Help button 
    ' with a normal state.
    ControlPaint.DrawCaptionButton(e.Graphics, Button1.ClientRectangle, _
        CaptionButton.Help, ButtonState.Normal)
End Sub

另请参阅

适用于