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

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

ButtonRenderer.DrawParentBackground メソッド

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

指定した領域コントロールの親の背景描画ます。

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

Public Shared Sub DrawParentBackground
 ( _
    g As Graphics, _
    bounds As Rectangle, _
    childControl As Control _
)
Dim g As Graphics
Dim bounds As Rectangle
Dim childControl As Control

ButtonRenderer.DrawParentBackground(g, bounds, childControl)
public static void DrawParentBackground
 (
    Graphics g,
    Rectangle bounds,
    Control childControl
)
public:
static void DrawParentBackground (
    Graphics^ g, 
    Rectangle bounds, 
    Control^ childControl
)
public static void DrawParentBackground
 (
    Graphics g, 
    Rectangle bounds, 
    Control childControl
)
public static function DrawParentBackground
 (
    g : Graphics, 
    bounds : Rectangle, 
    childControl : Control
)

パラメータ

g

childControl の親の背景描画するときに使用する Graphics

bounds

コントロール背景描画する Rectangle。この四角形は、子コントロール境界内に存在する必要があります

childControl

親の背景描画されるコントロール

使用例使用例

DrawParentBackground メソッド使用してカスタム コントロール領域塗りつぶすコード例を、次に示します。このコード例は、ButtonRenderer クラストピック取り上げているコード例一部分です。

' Draw the large or small button, depending on the current state.
Protected Overrides Sub
 OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    ' Draw the smaller pressed button image.
    If state = PushButtonState.Pressed Then
        ' Set the background color to the parent if visual styles  
        ' are disabled, because DrawParentBackground will only paint
  
        ' over the control background if visual styles are enabled.
        If Application.RenderWithVisualStyles Then
            Me.BackColor = Color.Azure
        Else
            Me.BackColor = Me.Parent.BackColor
        End If

        ' If you comment out the call to DrawParentBackground,   
        ' the background of the control will still be visible 
        ' outside the pressed button, if visual styles are enabled.
        ButtonRenderer.DrawParentBackground(e.Graphics, _
            Me.ClientRectangle, Me)
        ButtonRenderer.DrawButton(e.Graphics, ClickRectangle, _
            Me.Text, Me.Font, True,
 state)

    ' Draw the bigger unpressed button image.
    Else
        ButtonRenderer.DrawButton(e.Graphics, Me.ClientRectangle,
 _
            Me.Text, Me.Font, False,
 state)
    End If
End Sub
// Draw the large or small button, depending on the current state.
protected override void OnPaint(PaintEventArgs
 e)
{
    base.OnPaint(e);

    // Draw the smaller pressed button image
    if (state == PushButtonState.Pressed)
    {
        // Set the background color to the parent if visual styles 
 
        // are disabled, because DrawParentBackground will only paint
  
        // over the control background if visual styles are enabled.
        this.BackColor = Application.RenderWithVisualStyles ?
            Color.Azure : this.Parent.BackColor;

        // If you comment out the call to DrawParentBackground, 
        // the background of the control will still be visible 
        // outside the pressed button, if visual styles are enabled.
        ButtonRenderer.DrawParentBackground(e.Graphics,
            ClientRectangle, this);
        ButtonRenderer.DrawButton(e.Graphics, ClickRectangle,
            this.Text, this.Font, true,
 state);
    }

    // Draw the bigger unpressed button image.
    else
    {
        ButtonRenderer.DrawButton(e.Graphics, ClientRectangle,
            this.Text, this.Font, false,
 state);
    }
}
    // Draw the large or small button, depending on the current state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        // Draw the smaller pressed button image
        if (state == PushButtonState::Pressed)
        {
            // Set the background color to the parent if visual styles
            // are disabled, because DrawParentBackground will only
 paint
            // over the control background if visual styles are enabled.
            if (Application::RenderWithVisualStyles)
            {
                this->BackColor = Color::Azure;
            }
            else
            {
                this->BackColor = this->Parent->BackColor;
            }


            // If you comment out the call to DrawParentBackground,
            // the background of the control will still be visible
            // outside the pressed button, if visual styles are enabled.
            ButtonRenderer::DrawParentBackground(e->Graphics,
                ClientRectangle, this);
            ButtonRenderer::DrawButton(e->Graphics, ClickRectangle,
                this->Text, this->Font,
 true, state);
        }

        // Draw the bigger unpressed button image.
        else
        {
            ButtonRenderer::DrawButton(e->Graphics, ClientRectangle,
                this->Text, this->Font,
 false, state);
        }
    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

「ButtonRenderer.DrawParentBackground メソッド」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS