CMFCRibbonSlider Class
The CMFCRibbonSlider
class implements a slider control that you can add to a ribbon bar or ribbon status bar. The ribbon slider control resembles the zoom sliders that appear in Office 2007 applications.
class CMFCRibbonSlider : public CMFCRibbonBaseElement
Name | Description |
---|---|
CMFCRibbonSlider::CMFCRibbonSlider | Constructs and initializes a ribbon slider control. |
Name | Description |
---|---|
CMFCRibbonSlider::GetPos | Returns the current position of the slider control. |
CMFCRibbonSlider::GetRangeMax | Returns the maximum value of the slider. |
CMFCRibbonSlider::GetRangeMin | Returns the minimum value of the slider. |
CMFCRibbonSlider::GetRegularSize | Returns the regular size of the ribbon element. (Overrides CMFCRibbonBaseElement::GetRegularSize.) |
CMFCRibbonSlider::GetZoomIncrement | Returns the size of the zoom increment for the slider control. |
CMFCRibbonSlider::HasZoomButtons | Specifies whether the slider has zoom buttons. |
CMFCRibbonSlider::OnDraw | Called by the framework to draw the ribbon element. (Overrides CMFCRibbonBaseElement::OnDraw.) |
CMFCRibbonSlider::SetPos | Sets the current position of the slider control. |
CMFCRibbonSlider::SetRange | Specifies the range of the slider control by setting the minimum and maximum values. |
CMFCRibbonSlider::SetZoomButtons | Shows or hides the zoom buttons. |
CMFCRibbonSlider::SetZoomIncrement | Sets size of the zoom increment for the slider control. |
You can use the SetRange
method to configure the range of zoom increments for the slider. You can set current position of the slider by using the SetPos
method.
You can display circular zoom buttons on the left and right side of the slider control by using the SetZoomButtons
method. By default, the slider is horizontal, the left zoom button displays a minus sign and the right zoom button displays a plus sign.
The SetZoomIncrement
method defines the increment to add to or subtract from the current position when a user clicks the zoom buttons.
The following example demonstrates how to use various methods in the CMFCRibbonSlider
class to set the properties of the slider. The example shows how to construct a CMFCRibbonSlider
object, display zoom buttons, set the current position of the slider control, and set the range of values for the slider control.
// Create a ribbon slider.
CMFCRibbonSlider *ribbonSlider = new CMFCRibbonSlider();
// Set the various properties of the slider.
ribbonSlider->SetZoomButtons(true);
ribbonSlider->SetPos(50, TRUE);
ribbonSlider->SetRange(0, 100);
// Add the ribbon slider to the Favorites panel.
// CMFCRibbonPanel* pPanelFavorites
pPanelFavorites->Add(ribbonSlider);
Header: afxribbonslider.h
Construct a ribbon slider.
CMFCRibbonSlider(
UINT nID,
int nWidth=100);
nID
[in] Slider ID.
[in]. nWidth Slider width in pixels.
Constructs a ribbon slider that is nWidth pixels wide in the panel category where the slider is added. By default, the slider is horizontal.
Returns the current position of the slider control.
int GetPos() const;
The current position of the slider control, which is a position relative to the beginning of the slider.
Obtains the maximum increment of the slider that the slider can travel on the slider control.
int GetRangeMax() const;
The maximum increment of the slider that the slider can travel on the slider control.
Returns the minimum increment that the slider can travel on the slider control.
int GetRangeMin() const;
The minimum increment that the slider can travel on the slider control.
For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.
virtual CSize GetRegularSize(CDC* pDC);
[in] pDC
Obtain the zoom increment for the slider control.
int GetZoomIncrement() const;
The zoom increment for the slider control.
Specifies whether the slider has zoom buttons.
BOOL HasZoomButtons() const;
TRUE if the slider has zoom buttons; FALSE otherwise.
For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.
virtual void OnDraw(CDC* pDC);
[in] pDC
Set the current position of the slider control.
void SetPos(
int nPos,
BOOL bRedraw=TRUE);
nPos
[in] Specifies the position to set for the slider. The position is relative to the beginning of the slider.
bRedraw
[in] If TRUE, the slider will be redrawn.
Set the range of values for the slider control.
void SetRange(
int nMin,
int nMax);
nMin
[in] Specifies minimum value of the slider control.
nMax
[in] Specifies maximum value of the slider control.
Specifies the range of values for the slider control by setting the minimum and maximum values.
Display or hide zoom buttons.
void SetZoomButtons(BOOL bSet=TRUE);
[in]. bSet TRUE to display zoom buttons; FALSE to hide them.
Set the zoom increment for the slider control.
void SetZoomIncrement(int nZoomIncrement);
nZoomIncrement
[in] Specifies the zoom increment of the slider control.