共用方式為


VisualStyleRenderer.GetPartSize 方法

定義

為目前的視覺化樣式組件傳回指定的大小屬性值。

多載

GetPartSize(IDeviceContext, ThemeSizeType)

為目前的視覺化樣式組件傳回指定的大小屬性值。

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

使用指定所繪製界限,傳回目前視覺化樣式組件之指定的大小屬性值。

GetPartSize(IDeviceContext, ThemeSizeType)

來源:
VisualStyleRenderer.cs
來源:
VisualStyleRenderer.cs
來源:
VisualStyleRenderer.cs

為目前的視覺化樣式組件傳回指定的大小屬性值。

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,包含目前視覺化樣式組件之 type 參數指定的大小。

例外狀況

dcnull

prop 不是其中一個 ThemeSizeType 值。

範例

下列程式碼範例示範如何使用 GetPartSize(IDeviceContext, ThemeSizeType) 自訂控制項中的 方法,取得視窗標題列、 關閉 按鈕、框線和視覺化樣式所指定大小控點的大小。 這些大小可用來計算用來繪製 VisualStyleElement 代表這些視窗元件之物件的物件大小 Rectangle 。 此程式碼範例是類別概觀所提供較大範例的 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 使用 typeMinimum 值。

適用於

GetPartSize(IDeviceContext, Rectangle, ThemeSizeType)

來源:
VisualStyleRenderer.cs
來源:
VisualStyleRenderer.cs
來源:
VisualStyleRenderer.cs

使用指定所繪製界限,傳回目前視覺化樣式組件之指定的大小屬性值。

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,包含目前視覺化樣式組件之 type 參數指定的大小。

例外狀況

dcnull

prop 不是其中一個 ThemeSizeType 值。

適用於