共用方式為


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 值的位元 (Bitwise) 組合,指定繪製按鈕的狀態。

範例

下列程式碼範例示範 如何使用 ControlPaint.DrawCaptionButton 方法和 CaptionButton 列舉。 若要執行此範例,請將下列程式碼貼到包含名為 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 值的位元 (Bitwise) 組合,指定繪製按鈕的狀態。

範例

下列程式碼範例示範 如何使用 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

另請參閱

適用於