VisualStyleRenderer.DrawBackground Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Nakreslí obrázek pozadí aktuálního prvku vizuálního stylu.
Přetížení
| Name | Description |
|---|---|
| DrawBackground(IDeviceContext, Rectangle) |
Nakreslí obrázek pozadí aktuálního prvku vizuálního stylu v zadaném ohraničujícím obdélníku. |
| DrawBackground(IDeviceContext, Rectangle, Rectangle) |
Nakreslí obrázek pozadí aktuálního prvku vizuálního stylu v zadaném ohraničujícím obdélníku a oříznutý na zadaný obdélník výřezu. |
DrawBackground(IDeviceContext, Rectangle)
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
Nakreslí obrázek pozadí aktuálního prvku vizuálního stylu v zadaném ohraničujícím obdélníku.
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)
Parametry
Používá IDeviceContext se k vykreslení obrázku pozadí.
Výjimky
dc je null.
Příklady
Následující příklad kódu ukazuje, jak použít metodu DrawBackground(IDeviceContext, Rectangle) nakreslit VisualStyleElement uvnitř vlastního ovládacího prvku OnPaint metoda. Tento příklad kódu je součástí většího příkladu VisualStyleRenderer , který je k dispozici pro přehled třídy.
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
Poznámky
Tato metoda nakreslí pozadí aktuálního elementu vizuálního stylu určeného znakem Class, Parta State vlastnosti.
Width Pokud je hodnota nebo Height obdélník určený parametrem bounds menší než 0, DrawBackground vrátí se metoda bez vykreslení pozadí.
Pozadí elementu vizuálního stylu může být rastrový soubor nebo vyplněné ohraničení. Chcete-li určit typ pozadí, zavolejte metodu GetEnumValue s hodnotou argumentu EnumProperty.BackgroundType. Chcete-li zjistit, zda se pozadí prvku bude škálovat tak, aby odpovídalo zadaným hranicím, zavolejte metodu GetEnumValue s hodnotou argumentu EnumProperty.SizingType.
Platí pro
DrawBackground(IDeviceContext, Rectangle, Rectangle)
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
- Zdroj:
- VisualStyleRenderer.cs
Nakreslí obrázek pozadí aktuálního prvku vizuálního stylu v zadaném ohraničujícím obdélníku a oříznutý na zadaný obdélník výřezu.
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)
Parametry
Používá IDeviceContext se k vykreslení obrázku pozadí.
Výjimky
dc je null.
Poznámky
Tato metoda nakreslí pozadí aktuálního elementu vizuálního stylu určeného znakem Class, Parta State vlastnosti. Pozadí se ořízne do oblasti určené parametrem clipRectangle .
Width Pokud je nebo Height obdélník určený buď boundsclipRectangle nebo parametry menší než 0, DrawBackground vrátí metoda bez vykreslení pozadí.
Pozadí elementu vizuálního stylu může být rastrový soubor nebo vyplněné ohraničení. Chcete-li určit typ pozadí, zavolejte metodu GetEnumValue s hodnotou argumentu EnumProperty.BackgroundType. Chcete-li zjistit, zda se pozadí prvku bude škálovat tak, aby odpovídalo zadaným hranicím, zavolejte metodu GetEnumValue s hodnotou argumentu EnumProperty.SizingType.