VisualStyleRenderer.GetPartSize Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce il valore della proprietà size specificata della parte dello stile di visualizzazione corrente.
Overload
| Nome | Descrizione |
|---|---|
| GetPartSize(IDeviceContext, ThemeSizeType) |
Restituisce il valore della proprietà size specificata della parte dello stile di visualizzazione corrente. |
| GetPartSize(IDeviceContext, Rectangle, ThemeSizeType) |
Restituisce il valore della proprietà size specificata della parte dello stile di visualizzazione corrente utilizzando i limiti di disegno specificati. |
GetPartSize(IDeviceContext, ThemeSizeType)
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
Restituisce il valore della proprietà size specificata della parte dello stile di visualizzazione corrente.
public:
System::Drawing::Size GetPartSize(System::Drawing::IDeviceContext ^ dc, System::Windows::Forms::VisualStyles::ThemeSizeType type);
public System.Drawing.Size GetPartSize(System.Drawing.IDeviceContext dc, System.Windows.Forms.VisualStyles.ThemeSizeType type);
member this.GetPartSize : System.Drawing.IDeviceContext * System.Windows.Forms.VisualStyles.ThemeSizeType -> System.Drawing.Size
Public Function GetPartSize (dc As IDeviceContext, type As ThemeSizeType) As Size
Parametri
Questa IDeviceContext operazione verrà utilizzata.
- type
- ThemeSizeType
Uno dei ThemeSizeType valori che specifica il valore di dimensione da recuperare per la parte.
Valori restituiti
Oggetto Size contenente le dimensioni specificate dal type parametro per la parte dello stile di visualizzazione corrente.
Eccezioni
dc è null.
prop non è uno dei ThemeSizeType valori.
Esempio
Nell'esempio di codice seguente viene illustrato come utilizzare il GetPartSize(IDeviceContext, ThemeSizeType) metodo in un controllo personalizzato per ottenere le dimensioni di una barra del titolo della finestra, il pulsante Chiudi , i bordi e l'handle di ridimensionamento specificato dallo stile di visualizzazione. Queste dimensioni vengono utilizzate per calcolare le dimensioni degli Rectangle oggetti utilizzati per disegnare gli VisualStyleElement oggetti che rappresentano queste parti della finestra. Questo esempio di codice fa parte di un esempio più ampio fornito per la panoramica della VisualStyleRenderer classe.
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private:
void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application::RenderWithVisualStyles)
{
return;
}
Graphics^ g = this->CreateGraphics();
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer->GetPartSize(g, ThemeSizeType::True);
closeButtonOffset =
renderer->GetPoint(PointProperty::Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer->GetPartSize(g,
ThemeSizeType::True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer->GetPartSize(g,
ThemeSizeType::True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer->GetPartSize(g,
ThemeSizeType::True);
}
}
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application.RenderWithVisualStyles)
{
return;
}
using (Graphics g = this.CreateGraphics())
{
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer.GetPartSize(g, ThemeSizeType.True);
closeButtonOffset =
renderer.GetPoint(PointProperty.Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer.GetPartSize(g,
ThemeSizeType.True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer.GetPartSize(g,
ThemeSizeType.True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer.GetPartSize(g,
ThemeSizeType.True);
}
}
}
' Get the sizes and offsets for the window parts as specified
' by the visual style.
Private Sub GetPartDetails()
' Do nothing further if visual styles are not enabled.
If Not Application.RenderWithVisualStyles Then
Return
End If
Using g As Graphics = Me.CreateGraphics()
' Get the size and offset of the close button.
If SetRenderer(windowElements("windowClose")) Then
closeButtonSize = _
renderer.GetPartSize(g, ThemeSizeType.True)
closeButtonOffset = _
renderer.GetPoint(PointProperty.Offset)
End If
' Get the height of the window caption.
If SetRenderer(windowElements("windowCaption")) Then
captionHeight = renderer.GetPartSize(g, _
ThemeSizeType.True).Height
End If
' Get the thickness of the left, bottom, and right
' window frame.
If SetRenderer(windowElements("windowLeft")) Then
frameThickness = renderer.GetPartSize(g, _
ThemeSizeType.True).Width
End If
' Get the size of the resizing gripper.
If SetRenderer(windowElements("statusGripper")) Then
gripperSize = renderer.GetPartSize(g, _
ThemeSizeType.True)
End If
End Using
End Sub
Commenti
In genere, solo i True valori e Minimum devono essere usati per il type parametro di questo metodo.
Si applica a
GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
- Origine:
- VisualStyleRenderer.cs
Restituisce il valore della proprietà size specificata della parte dello stile di visualizzazione corrente utilizzando i limiti di disegno specificati.
public:
System::Drawing::Size GetPartSize(System::Drawing::IDeviceContext ^ dc, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::ThemeSizeType type);
public System.Drawing.Size GetPartSize(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.ThemeSizeType type);
member this.GetPartSize : System.Drawing.IDeviceContext * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.ThemeSizeType -> System.Drawing.Size
Public Function GetPartSize (dc As IDeviceContext, bounds As Rectangle, type As ThemeSizeType) As Size
Parametri
Questa IDeviceContext operazione verrà utilizzata.
- type
- ThemeSizeType
Uno dei ThemeSizeType valori che specifica il valore di dimensione da recuperare per la parte.
Valori restituiti
Oggetto Size contenente le dimensioni specificate dal type parametro per la parte dello stile di visualizzazione corrente.
Eccezioni
dc è null.
prop non è uno dei ThemeSizeType valori.