ScrollBarRenderer.DrawHorizontalThumbGrip メソッド

定義

visual スタイルを使用して、水平方向のスクロール ボックス (つまみとも呼ばれる) 上にグリップを描画します。

public:
 static void DrawHorizontalThumbGrip(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::ScrollBarState state);
public static void DrawHorizontalThumbGrip (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.ScrollBarState state);
static member DrawHorizontalThumbGrip : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.ScrollBarState -> unit
Public Shared Sub DrawHorizontalThumbGrip (g As Graphics, bounds As Rectangle, state As ScrollBarState)

パラメーター

g
Graphics

スクロール ボックスのグリップの描画に使用する Graphics

bounds
Rectangle

スクロール ボックスのグリップの境界を指定する Rectangle

state
ScrollBarState

スクロール ボックスのグリップの表示状態を指定する ScrollBarState 値の 1 つ。

例外

オペレーティング システムが visual スタイルをサポートしていません。

または

visual スタイルは、オペレーティング システムのユーザーにより無効にされています。

または

visual スタイルは、アプリケーション ウィンドウのクライアント領域には適用されません。

次のコード例では、 DrawHorizontalThumbGrip カスタム コントロールの メソッドの メソッドを使用して、マウス ポインターの OnPaint 位置によって決まる状態でスクロール ボックス グリップを描画します。 このコード例は、ScrollBarRenderer クラスのために提供されている大規模な例の一部です。

    // Draw the scroll bar in its normal state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        // Visual styles are not enabled.
        if (!ScrollBarRenderer::IsSupported)
        {
            this->Parent->Text = "CustomScrollBar Disabled";
            return;
        }

        this->Parent->Text = "CustomScrollBar Enabled";

        // Draw the scroll bar track.
        ScrollBarRenderer::DrawRightHorizontalTrack(e->Graphics,
            ClientRectangle, ScrollBarState::Normal);

        // Draw the thumb and thumb grip in the current state.
        ScrollBarRenderer::DrawHorizontalThumb(e->Graphics,
            thumbRectangle, thumbState);
        ScrollBarRenderer::DrawHorizontalThumbGrip(e->Graphics,
            thumbRectangle, thumbState);

        // Draw the scroll arrows in the current state.
        ScrollBarRenderer::DrawArrowButton(e->Graphics,
            leftArrowRectangle, leftButtonState);
        ScrollBarRenderer::DrawArrowButton(e->Graphics,
            rightArrowRectangle, rightButtonState);

        // Draw a highlighted rectangle in the left side of the scroll
        // bar track if the user has clicked between the left arrow
        // and thumb.
        if (leftBarClicked)
        {
            clickedBarRectangle.X = thumbLeftLimit;
            clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit;
            ScrollBarRenderer::DrawLeftHorizontalTrack(e->Graphics,
                clickedBarRectangle, ScrollBarState::Pressed);
        }

        // Draw a highlighted rectangle in the right side of the scroll
        // bar track if the user has clicked between the right arrow
        // and thumb.
        else if (rightBarClicked)
        {
            clickedBarRectangle.X =
                thumbRectangle.X + thumbRectangle.Width;
            clickedBarRectangle.Width =
                thumbRightLimitRight - clickedBarRectangle.X;
            ScrollBarRenderer::DrawRightHorizontalTrack(e->Graphics,
                clickedBarRectangle, ScrollBarState::Pressed);
        }
    }
// Draw the scroll bar in its normal state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    // Visual styles are not enabled.
    if (!ScrollBarRenderer.IsSupported)
    {
        this.Parent.Text = "CustomScrollBar Disabled";
        return;
    }

    this.Parent.Text = "CustomScrollBar Enabled";

    // Draw the scroll bar track.
    ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
        ClientRectangle, ScrollBarState.Normal);

    // Draw the thumb and thumb grip in the current state.
    ScrollBarRenderer.DrawHorizontalThumb(e.Graphics,
        thumbRectangle, thumbState);
    ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics,
        thumbRectangle, thumbState);

    // Draw the scroll arrows in the current state.
    ScrollBarRenderer.DrawArrowButton(e.Graphics,
            leftArrowRectangle, leftButtonState);
    ScrollBarRenderer.DrawArrowButton(e.Graphics,
            rightArrowRectangle, rightButtonState);

    // Draw a highlighted rectangle in the left side of the scroll 
    // bar track if the user has clicked between the left arrow 
    // and thumb.
    if (leftBarClicked)
    {
        clickedBarRectangle.X = thumbLeftLimit;
        clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit;
        ScrollBarRenderer.DrawLeftHorizontalTrack(e.Graphics,
            clickedBarRectangle, ScrollBarState.Pressed);
    }

    // Draw a highlighted rectangle in the right side of the scroll 
    // bar track if the user has clicked between the right arrow 
    // and thumb.
    else if (rightBarClicked)
    {
        clickedBarRectangle.X =
            thumbRectangle.X + thumbRectangle.Width;
        clickedBarRectangle.Width =
            thumbRightLimitRight - clickedBarRectangle.X;
        ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
            clickedBarRectangle, ScrollBarState.Pressed);
    }
}
' Draw the scroll bar in its normal state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    ' Visual styles are not enabled.
    If Not ScrollBarRenderer.IsSupported Then
        Me.Parent.Text = "CustomScrollBar Disabled"
        Return
    End If

    Me.Parent.Text = "CustomScrollBar Enabled"

    ' Draw the scroll bar track.
    ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics, _
        Me.ClientRectangle, ScrollBarState.Normal)

    ' Draw the thumb and thumb grip in the current state.
    ScrollBarRenderer.DrawHorizontalThumb(e.Graphics, _
        thumbRectangle, thumbState)
    ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics, _
        thumbRectangle, thumbState)

    ' Draw the scroll arrows in the current state.
    ScrollBarRenderer.DrawArrowButton(e.Graphics, _
        leftArrowRectangle, leftButtonState)
    ScrollBarRenderer.DrawArrowButton(e.Graphics, _
        rightArrowRectangle, rightButtonState)

    ' Draw a highlighted rectangle in the left side of the scroll 
    ' bar track if the user has clicked between the left arrow 
    ' and thumb.
    If leftBarClicked Then
        clickedBarRectangle.X = thumbLeftLimit
        clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit
        ScrollBarRenderer.DrawLeftHorizontalTrack(e.Graphics, _
            clickedBarRectangle, ScrollBarState.Pressed)

    ' Draw a highlighted rectangle in the right side of the scroll 
    ' bar track if the user has clicked between the right arrow 
    ' and thumb.
    ElseIf rightBarClicked Then
        clickedBarRectangle.X = thumbRectangle.X + _
            thumbRectangle.Width
        clickedBarRectangle.Width = thumbRightLimitRight - _
            clickedBarRectangle.X
        ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics, _
            clickedBarRectangle, ScrollBarState.Pressed)
    End If
End Sub

注釈

このメソッドを使用する前に、 プロパティから が IsSupported 返されることを確認する true必要があります。

適用対象