VisualStyleRenderer.GetPartSize メソッド

定義

現在の visual スタイル部品の、指定したサイズ プロパティの値を返します。

オーバーロード

GetPartSize(IDeviceContext, ThemeSizeType)

現在の visual スタイル部品の、指定したサイズ プロパティの値を返します。

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

指定した描画境界を使用している現在の visual スタイル部品の、指定したサイズ プロパティの値を返します。

GetPartSize(IDeviceContext, ThemeSizeType)

現在の visual スタイル部品の、指定したサイズ プロパティの値を返します。

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

パラメーター

dc
IDeviceContext

この操作で使用される IDeviceContext

type
ThemeSizeType

部品の取得するサイズ値を指定する ThemeSizeType 値。

戻り値

Size

現在の visual スタイル部品の type パラメーターで指定したサイズを含む Size

例外

dcnullです。

propThemeSizeType 値のいずれでもありません。

次のコード例は、カスタム コントロールのメソッドを GetPartSize(IDeviceContext, ThemeSizeType) 使用して、ビジュアル スタイルで指定されたウィンドウ タイトル バー、 閉じる ボタン、罫線、サイズ変更ハンドルのサイズを取得する方法を示しています。 これらのサイズは、これらのウィンドウ パーツを表すオブジェクトの Rectangle 描画に使用されるオブジェクトのサイズを VisualStyleElement 計算するために使用されます。 このコード例は、クラスの概要に関して提供されるより大きな例の VisualStyleRenderer 一部です。

    // 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

注釈

通常、このメソッドのパラメーターには True 、and Minimum 値のみを使用する type 必要があります。

適用対象

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

指定した描画境界を使用している現在の visual スタイル部品の、指定したサイズ プロパティの値を返します。

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

パラメーター

dc
IDeviceContext

この操作で使用される IDeviceContext

bounds
Rectangle

部品の描画先の領域を含む Rectangle

type
ThemeSizeType

部品の取得するサイズ値を指定する ThemeSizeType 値。

戻り値

Size

現在の visual スタイル部品の type パラメーターで指定したサイズを含む Size

例外

dcnullです。

propThemeSizeType 値のいずれでもありません。

適用対象