ScrollBarRenderer.IsSupported Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Получает значение, которое показывает, можно ли использовать класс ScrollBarRenderer для рисования полосы прокрутки с применением стилей оформления.
public:
static property bool IsSupported { bool get(); };
public static bool IsSupported { get; }
static member IsSupported : bool
Public Shared ReadOnly Property IsSupported As Boolean
Значение свойства
Значение true
, если пользователь включил в операционной системе стили оформления, и они применяются к клиентским областям окон приложений. В обратном случае — значение false
.
Примеры
В следующем примере кода свойство используется для IsSupported определения того, следует ли использовать ScrollBarRenderer методы . Этот пример входит в состав более крупного примера использования класса ScrollBarRenderer.
// Draw the scroll bar in its normal state.
protected:
virtual void OnPaint(PaintEventArgs^ e) override
{
__super::OnPaint(e);
// Visual styles are not enabled.
if (!ScrollBarRenderer::IsSupported)
{
this->Parent->Text = "CustomScrollBar Disabled";
return;
}
this->Parent->Text = "CustomScrollBar Enabled";
// Draw the scroll bar track.
ScrollBarRenderer::DrawRightHorizontalTrack(e->Graphics,
ClientRectangle, ScrollBarState::Normal);
// Draw the thumb and thumb grip in the current state.
ScrollBarRenderer::DrawHorizontalThumb(e->Graphics,
thumbRectangle, thumbState);
ScrollBarRenderer::DrawHorizontalThumbGrip(e->Graphics,
thumbRectangle, thumbState);
// Draw the scroll arrows in the current state.
ScrollBarRenderer::DrawArrowButton(e->Graphics,
leftArrowRectangle, leftButtonState);
ScrollBarRenderer::DrawArrowButton(e->Graphics,
rightArrowRectangle, rightButtonState);
// Draw a highlighted rectangle in the left side of the scroll
// bar track if the user has clicked between the left arrow
// and thumb.
if (leftBarClicked)
{
clickedBarRectangle.X = thumbLeftLimit;
clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit;
ScrollBarRenderer::DrawLeftHorizontalTrack(e->Graphics,
clickedBarRectangle, ScrollBarState::Pressed);
}
// Draw a highlighted rectangle in the right side of the scroll
// bar track if the user has clicked between the right arrow
// and thumb.
else if (rightBarClicked)
{
clickedBarRectangle.X =
thumbRectangle.X + thumbRectangle.Width;
clickedBarRectangle.Width =
thumbRightLimitRight - clickedBarRectangle.X;
ScrollBarRenderer::DrawRightHorizontalTrack(e->Graphics,
clickedBarRectangle, ScrollBarState::Pressed);
}
}
// Draw the scroll bar in its normal state.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Visual styles are not enabled.
if (!ScrollBarRenderer.IsSupported)
{
this.Parent.Text = "CustomScrollBar Disabled";
return;
}
this.Parent.Text = "CustomScrollBar Enabled";
// Draw the scroll bar track.
ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
ClientRectangle, ScrollBarState.Normal);
// Draw the thumb and thumb grip in the current state.
ScrollBarRenderer.DrawHorizontalThumb(e.Graphics,
thumbRectangle, thumbState);
ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics,
thumbRectangle, thumbState);
// Draw the scroll arrows in the current state.
ScrollBarRenderer.DrawArrowButton(e.Graphics,
leftArrowRectangle, leftButtonState);
ScrollBarRenderer.DrawArrowButton(e.Graphics,
rightArrowRectangle, rightButtonState);
// Draw a highlighted rectangle in the left side of the scroll
// bar track if the user has clicked between the left arrow
// and thumb.
if (leftBarClicked)
{
clickedBarRectangle.X = thumbLeftLimit;
clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit;
ScrollBarRenderer.DrawLeftHorizontalTrack(e.Graphics,
clickedBarRectangle, ScrollBarState.Pressed);
}
// Draw a highlighted rectangle in the right side of the scroll
// bar track if the user has clicked between the right arrow
// and thumb.
else if (rightBarClicked)
{
clickedBarRectangle.X =
thumbRectangle.X + thumbRectangle.Width;
clickedBarRectangle.Width =
thumbRightLimitRight - clickedBarRectangle.X;
ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
clickedBarRectangle, ScrollBarState.Pressed);
}
}
' Draw the scroll bar in its normal state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
' Visual styles are not enabled.
If Not ScrollBarRenderer.IsSupported Then
Me.Parent.Text = "CustomScrollBar Disabled"
Return
End If
Me.Parent.Text = "CustomScrollBar Enabled"
' Draw the scroll bar track.
ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics, _
Me.ClientRectangle, ScrollBarState.Normal)
' Draw the thumb and thumb grip in the current state.
ScrollBarRenderer.DrawHorizontalThumb(e.Graphics, _
thumbRectangle, thumbState)
ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics, _
thumbRectangle, thumbState)
' Draw the scroll arrows in the current state.
ScrollBarRenderer.DrawArrowButton(e.Graphics, _
leftArrowRectangle, leftButtonState)
ScrollBarRenderer.DrawArrowButton(e.Graphics, _
rightArrowRectangle, rightButtonState)
' Draw a highlighted rectangle in the left side of the scroll
' bar track if the user has clicked between the left arrow
' and thumb.
If leftBarClicked Then
clickedBarRectangle.X = thumbLeftLimit
clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit
ScrollBarRenderer.DrawLeftHorizontalTrack(e.Graphics, _
clickedBarRectangle, ScrollBarState.Pressed)
' Draw a highlighted rectangle in the right side of the scroll
' bar track if the user has clicked between the right arrow
' and thumb.
ElseIf rightBarClicked Then
clickedBarRectangle.X = thumbRectangle.X + _
thumbRectangle.Width
clickedBarRectangle.Width = thumbRightLimitRight - _
clickedBarRectangle.X
ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics, _
clickedBarRectangle, ScrollBarState.Pressed)
End If
End Sub
Комментарии
Если это свойство имеет значение false
, методы этого класса будут вызывать исключение InvalidOperationException.