Share via


TrackBarRenderer.DrawTopPointingThumb Método

Definición

Dibuja un control deslizante de barra de seguimiento ascendente (denominado también control de posición) con estilos visuales.

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)

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el control deslizante de barra de seguimiento.

bounds
Rectangle

Objeto Rectangle que especifica los límites del control deslizante de barra de seguimiento.

state
TrackBarThumbState

Uno de los valores TrackBarThumbState que especifica el estado visual del control deslizante de barra de seguimiento.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Ejemplos

En el ejemplo de código siguiente se usa el método en el DrawTopPointingThumb método de OnPaint un control personalizado para dibujar un control deslizante de barra de seguimiento que apunte hacia arriba. Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase TrackBarRenderer.

    // 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

Comentarios

Antes de llamar a este método, debe comprobar que el valor de la IsSupported propiedad es true.

Se aplica a