VisualStyleRenderer.DrawBackground 메서드

정의

현재 비주얼 스타일 요소의 배경 이미지를 그립니다.

오버로드

Name Description
DrawBackground(IDeviceContext, Rectangle)

지정된 경계 사각형 내에서 현재 비주얼 스타일 요소의 배경 이미지를 그립니다.

DrawBackground(IDeviceContext, Rectangle, Rectangle)

지정된 경계 사각형 내에서 현재 비주얼 스타일 요소의 배경 이미지를 그리고 지정된 클리핑 사각형으로 잘립니다.

DrawBackground(IDeviceContext, Rectangle)

Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs

지정된 경계 사각형 내에서 현재 비주얼 스타일 요소의 배경 이미지를 그립니다.

public:
 void DrawBackground(System::Drawing::IDeviceContext ^ dc, System::Drawing::Rectangle bounds);
public void DrawBackground(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds);
member this.DrawBackground : System.Drawing.IDeviceContext * System.Drawing.Rectangle -> unit
Public Sub DrawBackground (dc As IDeviceContext, bounds As Rectangle)

매개 변수

dc
IDeviceContext

IDeviceContext 배경 이미지를 그리는 데 사용됩니다.

bounds
Rectangle

Rectangle 배경 이미지가 그려지는 A입니다.

예외

dcnull입니다.

예제

다음 코드 예제에서는 사용자 지정 컨트롤의 DrawBackground(IDeviceContext, Rectangle) 메서드 내에서 그리 VisualStyleElement 기 메서드를 사용 OnPaint 하는 방법을 보여 줍니다. 이 코드 예제는 클래스 개요에 제공된 더 큰 예제의 VisualStyleRenderer 일부입니다.

protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        // Ensure that visual styles are supported.
        if (!Application::RenderWithVisualStyles)
        {
            this->Text = "Visual styles are not enabled.";
            TextRenderer::DrawText(e->Graphics, this->Text,
                this->Font, this->Location, this->ForeColor);
            return;
        }

        // Set the clip region to define the curved corners
        // of the caption.
        SetClipRegion();

        // Draw each part of the window.
        for each(KeyValuePair<String^, VisualStyleElement^>^ entry
            in windowElements)
        {
            if (SetRenderer(entry->Value))
            {
                renderer->DrawBackground(e->Graphics,
                    elementRectangles[entry->Key]);
            }
        }

        // Draw the caption text.
        TextRenderer::DrawText(e->Graphics, this->Text, this->Font,
            elementRectangles["windowCaption"], Color::White,
            TextFormatFlags::VerticalCenter |
            TextFormatFlags::HorizontalCenter);
    }
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    // Ensure that visual styles are supported.
    if (!Application.RenderWithVisualStyles)
    {
        this.Text = "Visual styles are not enabled.";
        TextRenderer.DrawText(e.Graphics, this.Text,
            this.Font, this.Location, this.ForeColor);
        return;
    }

    // Set the clip region to define the curved corners 
    // of the caption.
    SetClipRegion();

    // Draw each part of the window.
    foreach (KeyValuePair<string, VisualStyleElement> entry
        in windowElements)
    {
        if (SetRenderer(entry.Value))
        {
            renderer.DrawBackground(e.Graphics,
                elementRectangles[entry.Key]);
        }
    }

    // Draw the caption text.
    TextRenderer.DrawText(e.Graphics, this.Text, this.Font,
        elementRectangles["windowCaption"], Color.White,
        TextFormatFlags.VerticalCenter |
        TextFormatFlags.HorizontalCenter);
}
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    ' Ensure that visual styles are supported.
    If Not Application.RenderWithVisualStyles Then
        Me.Text = "Visual styles are not enabled."
        TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, _
            Me.Location, Me.ForeColor)
        Return
    End If

    ' Set the clip region to define the curved corners of 
    ' the caption.
    SetClipRegion()

    ' Draw each part of the window.
    Dim entry As KeyValuePair(Of String, VisualStyleElement)
    For Each entry In windowElements
        If SetRenderer(entry.Value) Then
            renderer.DrawBackground(e.Graphics, _
                elementRectangles(entry.Key))
        End If
    Next entry

    ' Draw the caption text.
    TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, _
        elementRectangles("windowCaption"), Color.White, _
        TextFormatFlags.VerticalCenter Or _
        TextFormatFlags.HorizontalCenter)
End Sub

설명

이 메서드는 , ClassPart 속성에 지정된 현재 비주얼 스타일 요소의 State배경을 그립니다.

매개 변수에 Width 지정된 사각형 또는 Height 사각형이 0보다 작으면 메서드는 bounds 배경을 그리지 DrawBackground 않고 반환됩니다.

비주얼 스타일 요소의 배경은 비트맵 파일 또는 채워진 테두리일 수 있습니다. 배경 형식을 확인하려면 인수 값GetEnumValue이 .EnumProperty.BackgroundType인 메서드를 호출합니다. 요소 배경이 지정된 경계에 맞게 크기 조정되는지 여부를 확인하려면 인수 값GetEnumValueEnumProperty.SizingType 있는 메서드를 호출합니다.

적용 대상

DrawBackground(IDeviceContext, Rectangle, Rectangle)

Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs
Source:
VisualStyleRenderer.cs

지정된 경계 사각형 내에서 현재 비주얼 스타일 요소의 배경 이미지를 그리고 지정된 클리핑 사각형으로 잘립니다.

public:
 void DrawBackground(System::Drawing::IDeviceContext ^ dc, System::Drawing::Rectangle bounds, System::Drawing::Rectangle clipRectangle);
public void DrawBackground(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, System.Drawing.Rectangle clipRectangle);
member this.DrawBackground : System.Drawing.IDeviceContext * System.Drawing.Rectangle * System.Drawing.Rectangle -> unit
Public Sub DrawBackground (dc As IDeviceContext, bounds As Rectangle, clipRectangle As Rectangle)

매개 변수

dc
IDeviceContext

IDeviceContext 배경 이미지를 그리는 데 사용됩니다.

bounds
Rectangle

Rectangle 배경 이미지가 그려지는 A입니다.

clipRectangle
Rectangle

Rectangle 그리기 작업에 대한 클리핑 사각형을 정의하는 A입니다.

예외

dcnull입니다.

설명

이 메서드는 , ClassPart 속성에 지정된 현재 비주얼 스타일 요소의 State배경을 그립니다. 배경이 매개 변수로 지정된 clipRectangle 영역으로 잘립니다.

Width Height 또는 bounds 매개 변수로 clipRectangle 지정된 사각형 또는 사각형이 0 DrawBackground 보다 작은 경우 메서드는 배경을 그리지 않고 반환합니다.

비주얼 스타일 요소의 배경은 비트맵 파일 또는 채워진 테두리일 수 있습니다. 배경 형식을 확인하려면 인수 값GetEnumValue이 .EnumProperty.BackgroundType인 메서드를 호출합니다. 요소 배경이 지정된 경계에 맞게 크기 조정되는지 여부를 확인하려면 인수 값GetEnumValueEnumProperty.SizingType 있는 메서드를 호출합니다.

적용 대상