VisualStyleRenderer.DrawBackground Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Az aktuális vizuális stíluselem háttérképének rajzolása.
Túlterhelések
| Name | Description |
|---|---|
| DrawBackground(IDeviceContext, Rectangle) |
A megadott határolókereten belül rajzolja meg az aktuális vizualizációstílus-elem háttérképét. |
| DrawBackground(IDeviceContext, Rectangle, Rectangle) |
A megadott határoló téglalapon belül rajzolja meg az aktuális vizualizációstílus-elem háttérképét, és a megadott kivágási téglalapra vágja. |
DrawBackground(IDeviceContext, Rectangle)
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
A megadott határolókereten belül rajzolja meg az aktuális vizualizációstílus-elem háttérképét.
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)
Paraméterek
A IDeviceContext háttérkép rajzolásához használt.
Kivételek
dc az null.
Példák
Az alábbi példakód bemutatja, hogyan használható a DrawBackground(IDeviceContext, Rectangle) metódus egy egyéni vezérlő metódusán VisualStyleElement belüli rajzraOnPaint. Ez a példakód egy nagyobb, az VisualStyleRenderer osztály áttekintéséhez megadott példa része.
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
Megjegyzések
Ez a metódus a , Classés Part tulajdonságok által megadott aktuális vizualizációstílus-elem hátterét Staterajzolja meg.
Ha a Width paraméter által Height megadott téglalap vagy bounds téglalap kisebb, mint 0, a metódus a DrawBackground háttér rajzolása nélkül tér vissza.
A vizuális stíluselemek háttere lehet bitképfájl vagy kitöltött szegély. A háttértípus meghatározásához hívja meg a GetEnumValue metódust a következő argumentumértékkel EnumProperty.BackgroundType: . Annak megállapításához, hogy az elemháttér a megadott korlátoknak megfelelően skálázható-e, hívja meg a GetEnumValue metódust a következő argumentumértékkel EnumProperty.SizingType: .
A következőre érvényes:
DrawBackground(IDeviceContext, Rectangle, Rectangle)
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
- Forrás:
- VisualStyleRenderer.cs
A megadott határoló téglalapon belül rajzolja meg az aktuális vizualizációstílus-elem háttérképét, és a megadott kivágási téglalapra vágja.
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)
Paraméterek
A IDeviceContext háttérkép rajzolásához használt.
Kivételek
dc az null.
Megjegyzések
Ez a metódus a , Classés Part tulajdonságok által megadott aktuális vizualizációstílus-elem hátterét Staterajzolja meg. A háttér a paraméter által clipRectangle megadott területre lesz vágva.
Ha a Width vagy paraméterek által Height megadott téglalap vagy boundsclipRectangle téglalap kisebb, mint 0, a metódus a DrawBackground háttér rajzolása nélkül tér vissza.
A vizuális stíluselemek háttere lehet bitképfájl vagy kitöltött szegély. A háttértípus meghatározásához hívja meg a GetEnumValue metódust a következő argumentumértékkel EnumProperty.BackgroundType: . Annak megállapításához, hogy az elemháttér a megadott korlátoknak megfelelően skálázható-e, hívja meg a GetEnumValue metódust a következő argumentumértékkel EnumProperty.SizingType: .