Editare

Partajați prin


CMFCRibbonCheckBox Class

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

Syntax

class CMFCRibbonCheckBox : public CMFCRibbonButton

Members

Public Constructors

Name Description
CMFCRibbonCheckBox::CMFCRibbonCheckBox The constructor.

Public Methods

Name Description
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.)

Remarks

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.

Inheritance Hierarchy

CObject

CMFCRibbonBaseElement

CMFCRibbonButton

CMFCRibbonCheckBox

Requirements

Header: afxribboncheckbox.h

CMFCRibbonCheckBox::CMFCRibbonCheckBox

Constructor of a ribbon check box object

CMFCRibbonCheckBox(
    UINT nID,
    LPCTSTR lpszText);

Parameters

nID
[in] Specifies command ID.

lpszText
[in] 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);

CMFCRibbonCheckBox::GetCompactSize

When overridden, gets the compact size of the check box.

virtual CSize GetCompactSize(CDC* pDC);

Parameters

pDC
[in] Pointer to the CDC associated with the check box.

Return Value

Returns a CSize object that contains the compact size of the check box.

Remarks

If not overridden, returns the intermediate size of the check box.

CMFCRibbonCheckBox::GetIntermediateSize

Gets the intermediate size of the check box.

virtual CSize GetIntermediateSize(CDC* pDC);

Parameters

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

Return Value

A CSize object containing the intermediate size of the check box.

Remarks

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

CMFCRibbonCheckBox::GetRegularSize

Gets the regular size of the check box.

virtual CSize GetRegularSize(CDC* pDC);

Parameters

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

Return Value

Returns a CSize object that contains the regular size of the check box.

Remarks

If not overridden, returns the intermediate size of the check box.

CMFCRibbonCheckBox::IsDrawTooltipImage

Indicates whether there is a tooltip image associated with the check box.

virtual BOOL IsDrawTooltipImage() const;

Return Value

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

Remarks

CMFCRibbonCheckBox::OnDraw

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

virtual void OnDraw(CDC* pDC);

Parameters

pDC
[in] Pointer to the CDC in which to draw the check box.

Remarks

CMFCRibbonCheckBox::OnDrawMenuImage

Called by the framework to draw a menu image for the check box.

virtual BOOL OnDrawMenuImage(CDC*, CRect);

Parameters

[in] CDC*
Pointer to the CDC associated with the check box.

CRect
[in] 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.

CMFCRibbonCheckBox::OnDrawOnList

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

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

Parameters

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

strText
[in] The display text.

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

rect
[in] The display rectangle for the check box.

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

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

Remarks

CMFCRibbonCheckBox::SetACCData

Sets the accessibility data for the check box.

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

Parameters

pParent
The parent window of the check box.

data
The accessibility data for the check box.

Return Value

Always returns TRUE.

Remarks

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

See also

Hierarchy Chart
Classes
CMFCRibbonPanel Class