CMFCRibbonCheckBox 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 CMFCRibbonCheckBox Class.

The CMFCRibbonCheckBox class implements a check box that you can add to a ribbon panel, Quick Access Toolbar, or popup menu.

class CMFCRibbonCheckBox : public CMFCRibbonButton  

Public Constructors

NameDescription
CMFCRibbonCheckBox::CMFCRibbonCheckBoxThe constructor.

Public Methods

NameDescription
CMFCRibbonCheckBox::GetCompactSize(Overrides CMFCRibbonButton::GetCompactSize.)
CMFCRibbonCheckBox::GetIntermediateSize(Overrides CMFCRibbonButton::GetIntermediateSize.)
CMFCRibbonCheckBox::GetRegularSize(Overrides CMFCRibbonButton::GetRegularSize.)
CMFCRibbonCheckBox::IsDrawTooltipImage(Overrides CMFCRibbonButton::IsDrawTooltipImage.)
CMFCRibbonCheckBox::OnDraw(Overrides CMFCRibbonButton::OnDraw.)
CMFCRibbonCheckBox::OnDrawMenuImage(Overrides CMFCRibbonBaseElement::OnDrawMenuImage.)
CMFCRibbonCheckBox::OnDrawOnList(Overrides CMFCRibbonButton::OnDrawOnList.)
CMFCRibbonCheckBox::SetACCData(Overrides CMFCRibbonButton::SetACCData.)

To use a CMFCRibbonCheckBox in your application, add the following constructor to your code:

CMFCRibbonCheckBox (UINT nID, LPCTSTR lpszText)  

where nID is the check box command ID and lpszText is the text label of the check box.

You can add a check box to a ribbon panel by using CMFCRibbonPanel::Add.

CObject

CMFCRibbonBaseElement

CMFCRibbonButton

CMFCRibbonCheckBox

Header: afxribboncheckbox.h

Constructor of a ribbon check box object

CMFCRibbonCheckBox(
    UINT nID,  
    LPCTSTR lpszText);

Parameters

[in] nID
Specifies command ID.

[in] lpszText
Specifies text label.

Return Value

Constructs a ribbon check box object.

Example

The following example demonstrates how to construct an object of the CMFCRibbonCheckBox class.

	strTemp.LoadString(IDS_RIBBON_STATUSBAR);
	CMFCRibbonButton* pBtnStatusBar = new CMFCRibbonCheckBox(ID_VIEW_STATUS_BAR, strTemp);

When overridden, gets the compact size of the checkbox.

virtual CSize GetCompactSize(CDC* pDC);

Parameters

[in] pDC
Pointer to the CDC associated with the checkbox.

Return Value

Returns a CSize object that contains the compact size of the checkbox.

Remarks

If not overridden, returns the intermediate size of the checkbox.

Gets the intermediate size of the checkbox.

virtual CSize GetIntermediateSize(CDC* pDC);

Parameters

[in] pDC
Pointer to the CDC associated with this checkbox.

Return Value

A CSize object containing the intermediate size of the checkbox.

Remarks

If not overridden, calculates the intermediate size as the default checkbox size ( AFX_CHECK_BOX_DEFAULT_SIZE) plus the text size, plus margins.

Gets the regular size of the checkbox.

virtual CSize GetRegularSize(CDC* pDC);

Parameters

[in] pDC
Pointer to the CDC object associated with this checkbox.

Return Value

Returns a CSize object that contains the regular size of the checkbox.

Remarks

If not overridden, returns the intermediate size of the checkbox.

Indicates whether there is a tooltip image associated with the checkbox.

virtual BOOL IsDrawTooltipImage() const;  

Return Value

Returns TRUE if there is a tooltip image associated with the checkbox, or FALSE if not.

Remarks

Called by the framework to draw the checkbox using a specified device context.

virtual void OnDraw(CDC* pDC);

Parameters

[in] pDC
Pointer to the CDC in which to draw the checkbox.

Remarks

Called by the framework to draw a menu image for the checkbox.

virtual BOOL OnDrawMenuImage(CDC*, CRect);

Parameters

[in] CDC*
Pointer to the CDC associated with the checkbox.

[in] CRect
A CRect object specifying the rectangle in which to draw the menu image.

Return Value

Returns TRUE if the image was drawn, or FALSE if not.

Remarks

If not overridden, returns FALSE.

Called by the framework to draw the checkbox in a commands list box.

virtual void OnDrawOnList(
    CDC* pDC,  
    CString strText,  
    int nTextOffset,  
    CRect rect,  
    BOOL bIsSelected,  
    BOOL bHighlighted);

Parameters

[in] pDC
Pointer to the device context in which to draw the checkbox.

[in] strText
The display text.

[in] nTextOffset
The distance, in pixels, from the left side of the list box to the display text.

[in] rect
The display rectangle for the checkbox.

[in] bIsSelected
TRUE if the checkbox is selected, or FALSE if not.

[in] bHighlighted
TRUE if the checkbox is highlighted, or FALSE if not.

Remarks

Sets the accessibility data for the checkbox.

virtual BOOL SetACCData(
    CWnd* pParent,  
    CAccessibilityData& data);

Parameters

pParent
The parent window of the checkbox.

data
The accessibility data for the checkbox.

Return Value

Always returns TRUE.

Remarks

By default this method sets the accessibility data for the checkbox and always returns TRUE. Override this method to set the accessibility data and return a value that indicates success or failure.

Hierarchy Chart
Classes
CMFCRibbonPanel Class

Show: