TrackBarRenderer.IsSupported 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示是否可使用 TrackBarRenderer 类以视觉样式绘制跟踪条。
public:
static property bool IsSupported { bool get(); };
public static bool IsSupported { get; }
member this.IsSupported : bool
Public Shared ReadOnly Property IsSupported As Boolean
属性值
如果用户已在操作系统中启用了视觉样式,并将视觉样式应用于应用程序窗口的工作区,则为 true
;否则为 false
。
示例
下面的代码示例使用 IsSupported 属性来确定是否使用 TrackBarRenderer 方法。 此代码示例是为类提供的大型示例的 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
注解
如果此属性为 false
此属性,则此类的方法将引发一个 InvalidOperationException。