VisualStyleRenderer.GetBackgroundRegion メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > VisualStyleRenderer.GetBackgroundRegion メソッドの意味・解説 

VisualStyleRenderer.GetBackgroundRegion メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在の visual スタイル要素背景領域返します

名前空間: System.Windows.Forms.VisualStyles
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function GetBackgroundRegion ( _
    dc As IDeviceContext, _
    bounds As Rectangle _
) As Region
Dim instance As VisualStyleRenderer
Dim dc As IDeviceContext
Dim bounds As Rectangle
Dim returnValue As Region

returnValue = instance.GetBackgroundRegion(dc, bounds)
public Region GetBackgroundRegion (
    IDeviceContext dc,
    Rectangle bounds
)
public:
Region^ GetBackgroundRegion (
    IDeviceContext^ dc, 
    Rectangle bounds
)
public Region GetBackgroundRegion (
    IDeviceContext dc, 
    Rectangle bounds
)
public function GetBackgroundRegion (
    dc : IDeviceContext, 
    bounds : Rectangle
) : Region

パラメータ

dc

この操作使用する IDeviceContext。

bounds

現在の visual スタイル要素背景領域全体を含む Rectangle

戻り値
現在の visual スタイル要素背景を含む Region

例外例外
例外種類条件

ArgumentNullException

dcnull 参照 (Visual Basic では Nothing) です。

解説解説
使用例使用例

次のコード例では、カスタム コントロールGetBackgroundRegion メソッド使用する方法示します。この例では、GetBackgroundRegion使用して、VisualStyleElement.Window.Caption.Active プロパティ返すウィンドウ タイトル バー要素Region取得しますまた、この Region使用してコントロールの Control.Region プロパティ設定し標準 Windows XP visual スタイルによって定義されている角の丸いウィンドウ タイトル バー表示されるようにします。このコード例は VisualStyleRenderer クラス概要取り上げているコード例一部分です。

' Calculate and set the clipping region for the control  
' so that the corners of the title bar are rounded.
Private Sub SetClipRegion()
    If Not Application.RenderWithVisualStyles
 Then
        Return
    End If

    Using g As Graphics = Me.CreateGraphics()
        ' Get the current region for the window caption.
        If SetRenderer(windowElements("windowCaption"))
 Then
            Dim clipRegion As Region = _
                renderer.GetBackgroundRegion(g, _
                elementRectangles("windowCaption"))

            ' Get the client rectangle, but exclude the   
            ' region of the window caption.
            Dim height As Integer
 = _
                CInt(clipRegion.GetBounds(g).Height)
            Dim nonCaptionRect As _
                New Rectangle(ClientRectangle.X, _
                ClientRectangle.Y + height, _
                ClientRectangle.Width, _
                ClientRectangle.Height - height)

            ' Add the rectangle to the caption region, and  
            ' make this region the form's clipping region.
            clipRegion.Union(nonCaptionRect)
            Me.Region = clipRegion
        End If
    End Using
End Sub
// Calculate and set the clipping region for the control  
// so that the corners of the title bar are rounded.
private void SetClipRegion()
{
    if (!Application.RenderWithVisualStyles)
    {
        return;
    }

    using (Graphics g = this.CreateGraphics())
    {
        // Get the current region for the window caption.
        if (SetRenderer(windowElements["windowCaption"]))
        {
            Region clipRegion = renderer.GetBackgroundRegion(
                g, elementRectangles["windowCaption"]);

            // Get the client rectangle, but exclude the region 
            // of the window caption.
            int height = (int)clipRegion.GetBounds(g).Height;
            Rectangle nonCaptionRect = new Rectangle(
                ClientRectangle.X,
                ClientRectangle.Y + height,
                ClientRectangle.Width,
                ClientRectangle.Height - height);

            // Add the rectangle to the caption region, and  
            // make this region the form's clipping region.
            clipRegion.Union(nonCaptionRect);
            this.Region = clipRegion;
        }
    }
}
    // Calculate and set the clipping region for the control
    // so that the corners of the title bar are rounded.
private:
    void SetClipRegion()
    {
        if (!Application::RenderWithVisualStyles)
        {
            return;
        }

        Graphics^ g = this->CreateGraphics();
        // Get the current region for the window caption.
        if (SetRenderer(windowElements["windowCaption"]))
        {
            System::Drawing::Region^ clipRegion =
                renderer->GetBackgroundRegion(g,
                elementRectangles["windowCaption"]);

            // Get the client rectangle, but exclude the region
            // of the window caption.
            int height = (int)clipRegion->GetBounds(g).Height;
            System::Drawing::Rectangle nonCaptionRect = Rectangle(
                ClientRectangle.X, ClientRectangle.Y + height,
                ClientRectangle.Width, ClientRectangle.Height - height);

            // Add the rectangle to the caption region, and
            // make this region the form's clipping region.
            clipRegion->Union(nonCaptionRect);
            this->Region = clipRegion;
        }

    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
VisualStyleRenderer クラス
VisualStyleRenderer メンバ
System.Windows.Forms.VisualStyles 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からVisualStyleRenderer.GetBackgroundRegion メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からVisualStyleRenderer.GetBackgroundRegion メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からVisualStyleRenderer.GetBackgroundRegion メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

VisualStyleRenderer.GetBackgroundRegion メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



VisualStyleRenderer.GetBackgroundRegion メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS