TrackBarRenderer.DrawTopPointingThumb 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
繪製具有視覺化樣式的上指 (Upward-Pointing) 追蹤列滑桿 (也稱為捲動方塊)。
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)
參數
- state
- TrackBarThumbState
其中一個 TrackBarThumbState 值,指定追蹤列滑桿的可見狀態。
例外狀況
範例
下列程式碼範例會 DrawTopPointingThumb 使用自訂控制項 OnPaint 方法中的 方法來繪製向上指向的追蹤列滑杆。 此程式碼範例是針對 類別提供的較大範例的 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
備註
呼叫這個方法之前,您應該先確認 屬性的值 IsSupported 是 true
。