CMFCRibbonButtonsGroup 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 CMFCRibbonButtonsGroup Class.
The CMFCRibbonButtonsGroup
class allows you to organize a set of ribbon buttons into a group. All buttons in the group are directly adjacent to each other horizontally and enclosed in a border.
Syntax
class CMFCRibbonButtonsGroup : public CMFCRibbonBaseElement
Members
Public Constructors
Name | Description |
---|---|
CMFCRibbonButtonsGroup::CMFCRibbonButtonsGroup | Constructs a CMFCRibbonButtonsGroup object. |
Public Methods
Name | Description |
---|---|
CMFCRibbonButtonsGroup::AddButton | Adds a button to a group. |
CMFCRibbonButtonsGroup::AddButtons | Adds a list of buttons to a group. |
CMFCRibbonButtonsGroup::GetButton | Returns a pointer to the button that is located at a specified index. |
CMFCRibbonButtonsGroup::GetCount | Returns the number of buttons in the group. |
CMFCRibbonButtonsGroup::GetImageSize | Returns the image size of the normal images in the ribbon group (overrides CMFCRibbonBaseElement::GetImageSize.) |
CMFCRibbonButtonsGroup::GetRegularSize | Returns the regular size of the ribbon element (overrides CMFCRibbonBaseElement::GetRegularSize.) |
CMFCRibbonButtonsGroup::HasImages | Reports whether the CMFCRibbonButtonsGroup object contains toolbar images. |
CMFCRibbonButtonsGroup::OnDrawImage | Draws the appropriate image for a specified button, depending on whether the button is normal, highlighted or disabled. |
CMFCRibbonButtonsGroup::RemoveAll | Removes all buttons from the CMFCRibbonButtonsGroup object. |
CMFCRibbonButtonsGroup::SetImages | Assigns images to the group. |
CMFCRibbonButtonsGroup::SetParentCategory | Sets the parent CMFCRibbonCategory of the CMFCRibbonButtonsGroup object and all the buttons within it (overrides CMFCRibbonBaseElement::SetParentCategory.) |
Remarks
The group is derived from CMFCBaseRibbonElement and can be manipulated as a single entity. You can position the group on any panel or popup menu.
Example
The following example demonstrates how to use various methods in the CMFCRibbonButtonsGroup
class. The example shows how to construct a CMFCRibbonButtonsGroup
object, assign images to the group of ribbon buttons, and add a button to the group of ribbon buttons. This code snippet is part of the Draw Client sample.
CMFCRibbonButtonsGroup* pSBGroup = new CMFCRibbonButtonsGroup;
CMFCToolBarImages images;
images.SetImageSize(CSize(14, 14));
CMFCToolBarImages hotimages;
hotimages.SetImageSize(CSize(14, 14));
if (images.Load(IDB_STATUSBAR_1) && hotimages.Load(IDB_STATUSBAR_2))
{
pSBGroup->SetImages(&images, &hotimages, NULL);
}
pSBGroup->AddButton(new CMFCRibbonButton(ID_FILE_PRINT_PREVIEW, _T(""), 0));
pSBGroup->AddButton(new CMFCRibbonButton(ID_FILE_SUMMARYINFO, _T(""), 1));
// CMFCRibbonStatusBar m_wndStatusBar
m_wndStatusBar.AddExtendedElement(pSBGroup, _T("View Shortcuts"));
Inheritance Hierarchy
Requirements
Header: afxribbonbuttonsgroup.h
CMFCRibbonButtonsGroup::AddButton
Adds a button to a group.
void AddButton(CMFCRibbonBaseElement* pButton);
Parameters
[in] pButton
A pointer to a button to add.
CMFCRibbonButtonsGroup::AddButtons
Adds a list of buttons to a group.
void AddButtons(
const CList<CMFCRibbonBaseElement*,CMFCRibbonBaseElement*>& lstButtons);
Parameters
[in] lstButtons
A list of pointers to the buttons that you want to add.
CMFCRibbonButtonsGroup::CMFCRibbonButtonsGroup
Constructs a CMFCRibbonButtonsGroup
object.
CMFCRibbonButtonsGroup();
CMFCRibbonButtonsGroup(CMFCRibbonBaseElement* pButton);
```
### Parameters
[in] `pButton`
Specifies a button to add to the newly created `CMFCRibbonButtonsGroup` object.
### Return Value
### Remarks
## <a name="cmfcribbonbuttonsgroup__getbutton"></a> CMFCRibbonButtonsGroup::GetButton
Returns a pointer to the button that is located at a specified index.
CMFCRibbonBaseElement* GetButton(int i) const;
### Parameters
[in] `i`
A zero-based index of a button to return.
### Return Value
A pointer to the button that is located at the specified index. `NULL` if the specified index is out of range.
### Remarks
## <a name="cmfcribbonbuttonsgroup__getcount"></a> CMFCRibbonButtonsGroup::GetCount
Returns the number of buttons in the group.
int GetCount() const;
### Return Value
The number of buttons in the group.
## <a name="cmfcribbonbuttonsgroup__getimagesize"></a> CMFCRibbonButtonsGroup::GetImageSize
Retrieves the source image size of the protected `CMFCToolBarImages` member `m_Images`.
const CSize GetImageSize() const;
### Return Value
Returns the source image size of the toolbar images, if any are present, or a `CSize` of zero if not.
### Remarks
## <a name="cmfcribbonbuttonsgroup__getregularsize"></a> CMFCRibbonButtonsGroup::GetRegularSize
Retrieves the maximum possible size of the ribbon group element.
virtual CSize GetRegularSize(CDC* pDC);
### Parameters
[in] `pDC`
Pointer to the device context of the ribbon group.
### Return Value
### Remarks
## <a name="cmfcribbonbuttonsgroup__hasimages"></a> CMFCRibbonButtonsGroup::HasImages
Reports whether the `CMFCRibbonButtonsGroup` object contains toolbar images.
BOOL HasImages() const;
### Return Value
Returns TRUE if the protected `CMFCToolBarImages` member `m_Images` contains any images, or FALSE if not.
### Remarks
## <a name="cmfcribbonbuttonsgroup__ondrawimage"></a> CMFCRibbonButtonsGroup::OnDrawImage
Draws the appropriate image for a specified button, depending on whether the button is normal, highlighted or disabled.
virtual void OnDrawImage( CDC* pDC,
CRect rectImage,
CMFCRibbonBaseElement* pButton,
int nImageIndex);
### Parameters
[in] `pDC`
Pointer to the device context of the `CMFCRibbonButtonsGroup` object.
[in] `rectImage`
The rectangle within which to draw the image.
[in] `pButton`
The button for which to draw the image.
[in] `nImageIndex`
The index of the image to draw on the button (in one of the three image arrays for normal, highlighted or disabled buttons).
### Remarks
## <a name="cmfcribbonbuttonsgroup__removeall"></a> CMFCRibbonButtonsGroup::RemoveAll
Removes all buttons from the `CMFCRibbonButtonsGroup` object.
void RemoveAll();
### Remarks
## <a name="cmfcribbonbuttonsgroup__setimages"></a> CMFCRibbonButtonsGroup::SetImages
Assigns images to the group of ribbon buttons.
void SetImages( CMFCToolBarImages* pImages,
CMFCToolBarImages* pHotImages,
CMFCToolBarImages* pDisabledImages);
### Parameters
[in] `pImages`
Regular images.
[in] `pHotImages`
Hot images.
[in] `pDisabledImages`
Disabled images.
### Remarks
Call `SetImages` before you add buttons to a group. The number of images must be greater or equal to the number of buttons to be added to the group.
> [!NOTE]
> Hot images are images that are displayed when the user hovers over the button. Disabled images are images that are displayed when the button is disabled.
## <a name="cmfcribbonbuttonsgroup__setparentcategory"></a> CMFCRibbonButtonsGroup::SetParentCategory
Sets the parent `CMFCRibbonCategory` of the `CMFCRibbonButtonsGroup` object and all the buttons within it.
virtual void SetParentCategory(CMFCRibbonCategory* pCategory);
### Parameters
[in] `pCategory`
Pointer to the parent category to set (the tabbed groups in ribbon controls are called categories).
### Remarks
## See Also
[Hierarchy Chart](../Topic/Hierarchy%20Chart.md)
[Classes](../Topic/MFC%20Classes.md)