TrackBarRenderer::IsSupported Property
.NET Framework (current version)
Gets a value indicating whether the TrackBarRenderer class can be used to draw a track bar with visual styles.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System::Booleantrue if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, false.
If this property is false, the methods of this class will throw an InvalidOperationException.
The following code example uses the IsSupported property to determine whether to use the TrackBarRenderer methods. This code example is part of a larger example provided for the TrackBarRenderer class.
// 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();
}
.NET Framework
Available since 2.0
Available since 2.0
Show: