VisualStyleRenderer.GetBackgroundRegion メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As VisualStyleRenderer Dim dc As IDeviceContext Dim bounds As Rectangle Dim returnValue As Region returnValue = instance.GetBackgroundRegion(dc, bounds)
戻り値
現在の visual スタイル要素の背景を含む Region。



次のコード例では、カスタム コントロールで 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; } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からVisualStyleRenderer.GetBackgroundRegion メソッドを検索する場合は、下記のリンクをクリックしてください。

- VisualStyleRenderer.GetBackgroundRegion メソッドのページへのリンク