ButtonRenderer.DrawButton 메서드

정의

Button 컨트롤을 그립니다.

오버로드

DrawButton(Graphics, Rectangle, PushButtonState)

지정된 상태와 범위로 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, String, Font, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, String, Font, TextFormatFlags, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 텍스트 서식 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, String, Font, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 텍스트 서식, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

DrawButton(Graphics, Rectangle, PushButtonState)

지정된 상태와 범위로 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, image As Image, imageBounds As Rectangle, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

image
Image

단추에 그릴 Image입니다.

imageBounds
Rectangle

image의 크기를 나타내는 Rectangle입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, String, Font, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ buttonText, System::Drawing::Font ^ font, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string buttonText, System.Drawing.Font font, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? buttonText, System.Drawing.Font? font, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, buttonText As String, font As Font, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

buttonText
String

단추에 그릴 String입니다.

font
Font

buttonText에 적용할 Font입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

예제

다음 코드 예제에서는 합니다 DrawButton(Graphics, Rectangle, String, Font, Boolean, PushButtonState) 메서드는 사용자 지정 컨트롤의 OnPaint 마우스 포인터의 위치에 따라 결정 되는 상태로 단추를 그리기 위한 방법입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ButtonRenderer 클래스입니다.

    // Draw the large or small button, depending on the current state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        // Draw the smaller pressed button image
        if (state == PushButtonState::Pressed)
        {
            // Set the background color to the parent if visual styles
            // are disabled, because DrawParentBackground will only paint
            // over the control background if visual styles are enabled.
            if (Application::RenderWithVisualStyles)
            {
                this->BackColor = Color::Azure;
            }
            else
            {
                this->BackColor = this->Parent->BackColor;
            }


            // If you comment out the call to DrawParentBackground,
            // the background of the control will still be visible
            // outside the pressed button, if visual styles are enabled.
            ButtonRenderer::DrawParentBackground(e->Graphics,
                ClientRectangle, this);
            ButtonRenderer::DrawButton(e->Graphics, ClickRectangle,
                this->Text, this->Font, true, state);
        }

        // Draw the bigger unpressed button image.
        else
        {
            ButtonRenderer::DrawButton(e->Graphics, ClientRectangle,
                this->Text, this->Font, false, state);
        }
    }

    // Draw the smaller pressed button image.
protected:
    virtual void OnMouseDown(MouseEventArgs^ e) override
    {
        __super::OnMouseDown(e);
        this->Text = "Clicked!";
        state = PushButtonState::Pressed;
        Invalidate();
    }

    // Draw the button in the hot state.
protected:
    virtual void OnMouseEnter(EventArgs^ e) override
    {
        __super::OnMouseEnter(e);
        this->Text = "Click here";
        state = PushButtonState::Hot;
        Invalidate();
    }

    // Draw the button in the unpressed state.
protected:
    virtual void OnMouseLeave(EventArgs^ e) override
    {
        __super::OnMouseLeave(e);
        this->Text = "Click here";
        state = PushButtonState::Normal;
        Invalidate();
    }
// Draw the large or small button, depending on the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    // Draw the smaller pressed button image
    if (state == PushButtonState.Pressed)
    {
        // Set the background color to the parent if visual styles  
        // are disabled, because DrawParentBackground will only paint  
        // over the control background if visual styles are enabled.
        this.BackColor = Application.RenderWithVisualStyles ?
            Color.Azure : this.Parent.BackColor;

        // If you comment out the call to DrawParentBackground, 
        // the background of the control will still be visible 
        // outside the pressed button, if visual styles are enabled.
        ButtonRenderer.DrawParentBackground(e.Graphics,
            ClientRectangle, this);
        ButtonRenderer.DrawButton(e.Graphics, ClickRectangle,
            this.Text, this.Font, true, state);
    }

    // Draw the bigger unpressed button image.
    else
    {
        ButtonRenderer.DrawButton(e.Graphics, ClientRectangle,
            this.Text, this.Font, false, state);
    }
}

// Draw the smaller pressed button image.
protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);
    this.Text = "Clicked!";
    state = PushButtonState.Pressed;
    Invalidate();
}

// Draw the button in the hot state. 
protected override void OnMouseEnter(EventArgs e)
{
    base.OnMouseEnter(e);
    this.Text = "Click here";
    state = PushButtonState.Hot;
    Invalidate();
}

// Draw the button in the unpressed state.
protected override void OnMouseLeave(EventArgs e)
{
    base.OnMouseLeave(e);
    this.Text = "Click here";
    state = PushButtonState.Normal;
    Invalidate();
}
' Draw the large or small button, depending on the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    ' Draw the smaller pressed button image.
    If state = PushButtonState.Pressed Then
        ' Set the background color to the parent if visual styles  
        ' are disabled, because DrawParentBackground will only paint  
        ' over the control background if visual styles are enabled.
        If Application.RenderWithVisualStyles Then
            Me.BackColor = Color.Azure
        Else
            Me.BackColor = Me.Parent.BackColor
        End If

        ' If you comment out the call to DrawParentBackground,   
        ' the background of the control will still be visible 
        ' outside the pressed button, if visual styles are enabled.
        ButtonRenderer.DrawParentBackground(e.Graphics, _
            Me.ClientRectangle, Me)
        ButtonRenderer.DrawButton(e.Graphics, ClickRectangle, _
            Me.Text, Me.Font, True, state)

    ' Draw the bigger unpressed button image.
    Else
        ButtonRenderer.DrawButton(e.Graphics, Me.ClientRectangle, _
            Me.Text, Me.Font, False, state)
    End If
End Sub

' Draw the smaller pressed button image.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    MyBase.OnMouseDown(e)
    With Me
        .Text = "Clicked!"
        .state = PushButtonState.Pressed
    End With
    Invalidate()
End Sub

' Draw the button in the hot state. 
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
    MyBase.OnMouseEnter(e)
    With Me
        .Text = "Click here"
        .state = PushButtonState.Hot
    End With
    Invalidate()
End Sub

' Draw the button in the unpressed state.
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
    MyBase.OnMouseLeave(e)
    With Me
        .Text = "Click here"
        .state = PushButtonState.Normal
    End With
    Invalidate()
End Sub

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, String, Font, TextFormatFlags, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 텍스트 서식 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ buttonText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string buttonText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? buttonText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, buttonText As String, font As Font, flags As TextFormatFlags, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

buttonText
String

단추에 그릴 String입니다.

font
Font

buttonText에 적용할 Font입니다.

flags
TextFormatFlags

buttonText에 적용할 TextFormatFlags 값의 비트 조합입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, String, Font, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ buttonText, System::Drawing::Font ^ font, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string buttonText, System.Drawing.Font font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? buttonText, System.Drawing.Font? font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, buttonText As String, font As Font, image As Image, imageBounds As Rectangle, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

buttonText
String

단추에 그릴 String입니다.

font
Font

buttonText에 적용할 Font입니다.

image
Image

단추에 그릴 Image입니다.

imageBounds
Rectangle

image의 크기를 나타내는 Rectangle입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상

DrawButton(Graphics, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, PushButtonState)

지정된 상태, 범위, 텍스트, 텍스트 서식, 이미지 및 포커스 영역(선택 사항)을 사용하여 단추 컨트롤을 그립니다.

public:
 static void DrawButton(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ buttonText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string buttonText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
public static void DrawButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? buttonText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state);
static member DrawButton : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.PushButtonState -> unit
Public Shared Sub DrawButton (g As Graphics, bounds As Rectangle, buttonText As String, font As Font, flags As TextFormatFlags, image As Image, imageBounds As Rectangle, focused As Boolean, state As PushButtonState)

매개 변수

g
Graphics

단추를 그릴 때 사용되는 Graphics입니다.

bounds
Rectangle

단추의 범위를 지정하는 Rectangle입니다.

buttonText
String

단추에 그릴 String입니다.

font
Font

buttonText에 적용할 Font입니다.

flags
TextFormatFlags

buttonText에 적용할 TextFormatFlags 값의 비트 조합입니다.

image
Image

단추에 그릴 Image입니다.

imageBounds
Rectangle

image의 크기를 나타내는 Rectangle입니다.

focused
Boolean

단추에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.

state
PushButtonState

단추의 표시 상태를 지정하는 PushButtonState 값 중 하나입니다.

설명

운영 체제에서 비주얼 스타일을 사용 하 고 현재 애플리케이션에 비주얼 스타일을 적용 하는 경우이 메서드는 현재 비주얼 스타일을 사용 하 여 단추를 그립니다. 그렇지 않은 경우 클래식 Windows 스타일을 사용 하 여 단추를 그려집니다.

적용 대상