ControlPaint.DrawCaptionButton 方法

定义

绘制标题按钮控件。

重载

DrawCaptionButton(Graphics, Rectangle, CaptionButton, ButtonState)

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

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

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

DrawCaptionButton(Graphics, Rectangle, CaptionButton, ButtonState)

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

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 枚举。 若要运行此示例,请将以下代码粘贴到包含名为 的 Button 的 Button1窗体中。 窗体应导入 System.Windows.FormsSystem.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)

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

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 枚举。 若要运行此示例,请将以下代码粘贴到包含名为 Button1Button窗体中。 窗体应导入 System.Windows.FormsSystem.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

另请参阅

适用于