Share via


VisualStyleRenderer.GetPartSize Méthode

Définition

Renvoie la valeur de la propriété de taille spécifiée de la partie de style visuel en cours.

Surcharges

GetPartSize(IDeviceContext, ThemeSizeType)

Renvoie la valeur de la propriété de taille spécifiée de la partie de style visuel en cours.

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

Renvoie la valeur de la propriété de taille spécifiée de la partie de style visuel en cours à l'aide des limites de dessin spécifiées.

GetPartSize(IDeviceContext, ThemeSizeType)

Renvoie la valeur de la propriété de taille spécifiée de la partie de style visuel en cours.

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

Paramètres

dc
IDeviceContext

IDeviceContext que cette opération va utiliser.

type
ThemeSizeType

L'une des valeurs ThemeSizeType qui spécifie la valeur de taille à récupérer pour la partie.

Retours

Size qui contient la taille spécifiée par le paramètre type de la partie de style visuel en cours.

Exceptions

dc a la valeur null.

prop ne fait pas partie des valeurs ThemeSizeType.

Exemples

L’exemple de code suivant montre comment utiliser la GetPartSize(IDeviceContext, ThemeSizeType) méthode dans un contrôle personnalisé pour obtenir les tailles d’une barre de titre de fenêtre, du bouton Fermer , des bordures et de la poignée de dimensionnement spécifiées par le style visuel. Ces tailles sont utilisées pour calculer les tailles des Rectangle objets utilisés pour dessiner les VisualStyleElement objets qui représentent ces parties de fenêtre. Cet exemple de code fait partie d’un exemple plus large fourni pour la vue d’ensemble de la 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

Remarques

En règle générale, seules les True valeurs et Minimum doivent être utilisées pour le type paramètre de cette méthode.

S’applique à

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

Renvoie la valeur de la propriété de taille spécifiée de la partie de style visuel en cours à l'aide des limites de dessin spécifiées.

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

Paramètres

dc
IDeviceContext

IDeviceContext que cette opération va utiliser.

bounds
Rectangle

Rectangle qui contient la zone dans laquelle la partie est dessinée.

type
ThemeSizeType

L'une des valeurs ThemeSizeType qui spécifie la valeur de taille à récupérer pour la partie.

Retours

Size qui contient la taille spécifiée par le paramètre type de la partie de style visuel en cours.

Exceptions

dc a la valeur null.

prop ne fait pas partie des valeurs ThemeSizeType.

S’applique à