ButtonRenderer.DrawParentBackground(Graphics, Rectangle, Control) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 영역에 컨트롤 부모의 배경을 그립니다.
public:
static void DrawParentBackground(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::Control ^ childControl);
public static void DrawParentBackground (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.Control childControl);
static member DrawParentBackground : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.Control -> unit
Public Shared Sub DrawParentBackground (g As Graphics, bounds As Rectangle, childControl As Control)
매개 변수
- childControl
- Control
부모의 배경을 그릴 컨트롤입니다.
예제
다음 코드 예제에서는 DrawParentBackground 사용자 지정 컨트롤의 영역을 페인트 하는 방법입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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 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 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