CMFCRibbonSlider Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at 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.

Syntax

class CMFCRibbonSlider : public CMFCRibbonBaseElement  

Members

Public Constructors

Name Description
CMFCRibbonSlider::CMFCRibbonSlider Constructs and initializes a ribbon slider control.

Public Methods

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.

Remarks

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.

Example

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);

Inheritance Hierarchy

CObject

CMFCRibbonBaseElement

CMFCRibbonSlider

Requirements

Header: afxribbonslider.h

CMFCRibbonSlider::CMFCRibbonSlider

Construct a ribbon slider.

CMFCRibbonSlider(
    UINT nID,  
    int nWidth=100);

Parameters

[in] nID
Slider ID.

[in]. nWidth
Slider width in pixels.

Remarks

Constructs a ribbon slider that is nWidth pixels wide in the panel category where the slider is added. By default, the slider is horizontal.

CMFCRibbonSlider::GetPos

Returns the current position of the slider control.

int GetPos () const;  

Return Value

The current position of the slider control, which is a position relative to the beginning of the slider.

CMFCRibbonSlider::GetRangeMax

Obtains the maximum increment of the slider that the slider can travel on the slider control.

int GetRangeMax() const;  

Return Value

The maximum increment of the slider that the slider can travel on the slider control.

CMFCRibbonSlider::GetRangeMin

Returns the minimum increment that the slider can travel on the slider control.

int GetRangeMin() const;  

Return Value

The minimum increment that the slider can travel on the slider control.

CMFCRibbonSlider::GetRegularSize

This topic is included for completeness. 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);

Parameters

[in] pDC

Return Value

Remarks

CMFCRibbonSlider::GetZoomIncrement

Obtain the zoom increment for the slider control.

int GetZoomIncrement() const;  

Return Value

The zoom increment for the slider control.

CMFCRibbonSlider::HasZoomButtons

Specifies whether the slider has zoom buttons.

BOOL HasZoomButtons() const;  

Return Value

TRUE if the slider has zoom buttons; FALSE otherwise.

CMFCRibbonSlider::OnDraw

This topic is included for completeness. 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);

Parameters

[in] pDC

Remarks

CMFCRibbonSlider::SetPos

Set the current position of the slider control.

void SetPos(
    int nPos,  
    BOOL bRedraw = TRUE);

Parameters

[in] nPos
Specifies the position to set for the slider. The position is relative to the beginning of the slider.

[in] bRedraw
If TRUE, the slider will be redrawn.

CMFCRibbonSlider::SetRange

Set the range of values for the slider control.

void SetRange(
    int nMin,  
    int nMax);

Parameters

[in] nMin
Specifies minimum value of the slider control.

[in] nMax
Specifies maximum value of the slider control.

Remarks

Specifies the range of values for the slider control by setting the minimum and maximum values.

CMFCRibbonSlider::SetZoomButtons

Display or hide zoom buttons.

void SetZoomButtons(BOOL bSet=TRUE);

Parameters

[in]. bSet
TRUE to display zoom buttons; FALSE to hide them.

CMFCRibbonSlider::SetZoomIncrement

Set the zoom increment for the slider control.

void SetZoomIncrement(int nZoomIncrement);

Parameters

[in] nZoomIncrement
Specifies the zoom increment of the slider control.

See Also

Hierarchy Chart
Classes
CMFCRibbonBaseElement Class