VisualStyleRenderer.DrawBackground 메서드

정의

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

오버로드

DrawBackground(IDeviceContext, Rectangle)

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

DrawBackground(IDeviceContext, Rectangle, Rectangle)

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

DrawBackground(IDeviceContext, Rectangle)

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

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입니다.

예외

dc이(가) null인 경우

예제

다음 코드 예제에서는 사용자 지정 컨트롤의 OnPaint 메서드 내에서 그리 VisualStyleElement 기 위해 메서드를 사용 DrawBackground(IDeviceContext, Rectangle) 하는 방법을 보여 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

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

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

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

적용 대상

DrawBackground(IDeviceContext, Rectangle, Rectangle)

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

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입니다.

clipRectangle
Rectangle

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

예외

dc이(가) null인 경우

설명

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

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

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

적용 대상