TrackBarRenderer.DrawTopPointingThumb Metodo

Definizione

Disegna un dispositivo di scorrimento (noto anche come casella) di un indicatore di avanzamento rivolto verso l'alto con stili di visualizzazione.

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

Parametri

g
Graphics

Oggetto Graphics utilizzato per disegnare il dispositivo di scorrimento della barra di avanzamento.

bounds
Rectangle

Oggetto Rectangle che specifica i limiti del dispositivo di scorrimento della barra di avanzamento.

state
TrackBarThumbState

Uno dei valori TrackBarThumbState che specifica lo stato di visualizzazione del dispositivo di scorrimento della barra di avanzamento.

Eccezioni

Il sistema operativo non supporta gli stili di visualizzazione.

-oppure-

Gli stili di visualizzazione sono stati disabilitati dall'utente nel sistema operativo.

-oppure-

Gli stili di visualizzazione non sono stati applicati all'area client delle finestre dell'applicazione.

Esempio

Nell'esempio di codice seguente viene usato il DrawTopPointingThumb metodo nel metodo di OnPaint un controllo personalizzato per disegnare un dispositivo di scorrimento della barra di traccia verso l'alto. Questo esempio di codice fa parte di un esempio più grande fornito per la TrackBarRenderer classe.

    // Draw the track bar.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        if (!TrackBarRenderer::IsSupported)
        {
            this->Parent->Text = "CustomTrackBar Disabled";
            return;
        }

        this->Parent->Text = "CustomTrackBar Enabled";
        TrackBarRenderer::DrawHorizontalTrack(e->Graphics,
            trackRectangle);
        TrackBarRenderer::DrawTopPointingThumb(e->Graphics,
            thumbRectangle, thumbState);
        TrackBarRenderer::DrawHorizontalTicks(e->Graphics,
            ticksRectangle, numberTicks, EdgeStyle::Raised);
    }

    // Determine whether the user has clicked the track bar thumb.
protected:
    virtual void OnMouseDown(MouseEventArgs^ e) override
    {
        if (!TrackBarRenderer::IsSupported)
        {
            return;
        }
        if (this->thumbRectangle.Contains(e->Location))
        {
            thumbClicked = true;
            thumbState = TrackBarThumbState::Pressed;
        }

        this->Invalidate();
    }
// Draw the track bar.
protected override void OnPaint(PaintEventArgs e)
{
    if (!TrackBarRenderer.IsSupported)
    {
        this.Parent.Text = "CustomTrackBar Disabled";
        return;
    }

    this.Parent.Text = "CustomTrackBar Enabled";
    TrackBarRenderer.DrawHorizontalTrack(e.Graphics,
        trackRectangle);
    TrackBarRenderer.DrawTopPointingThumb(e.Graphics,
        thumbRectangle, thumbState);
    TrackBarRenderer.DrawHorizontalTicks(e.Graphics,
        ticksRectangle, numberTicks, EdgeStyle.Raised);
}

// Determine whether the user has clicked the track bar thumb.
protected override void OnMouseDown(MouseEventArgs e)
{
    if (!TrackBarRenderer.IsSupported)
        return;

    if (this.thumbRectangle.Contains(e.Location))
    {
        thumbClicked = true;
        thumbState = TrackBarThumbState.Pressed;
    }

    this.Invalidate();
}
' Draw the track bar.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    If Not TrackBarRenderer.IsSupported Then
        Me.Parent.Text = "CustomTrackBar Disabled"
        Return
    End If

    Me.Parent.Text = "CustomTrackBar Enabled"
    TrackBarRenderer.DrawHorizontalTrack(e.Graphics, _
        trackRectangle)
    TrackBarRenderer.DrawTopPointingThumb(e.Graphics, _
        thumbRectangle, thumbState)
    TrackBarRenderer.DrawHorizontalTicks(e.Graphics, _
        ticksRectangle, numberTicks, EdgeStyle.Raised)
End Sub

' Determine whether the user has clicked the track bar thumb.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    If Not TrackBarRenderer.IsSupported Then
        Return
    End If
    If Me.thumbRectangle.Contains(e.Location) Then
        thumbClicked = True
        thumbState = TrackBarThumbState.Pressed
    End If

    Me.Invalidate()
End Sub

Commenti

Prima di chiamare questo metodo, è necessario verificare che il valore della IsSupported proprietà sia true.

Si applica a