Called by the framework when a ribbon event occurs.
virtual CXlOper OnRibbonEvent( const CRibbonEvtParams& e ); |
A set of event arguments contained in a CRibbonEvtParams object.
The method should return a value of a type expected for the callback being handled. See RibbonCallbackTypes enumeration for a list of these types. See "Callback types" below for a list of the expected return values and types.
If this virtual method is implemented by an application class, then the method should first call the base class method, for example as in the code below:
CXlOper CRibbonApp::OnRibbonEvent(const CRibbonEvtParams& e) { CXlOper xloResult = CXllApp::OnRibbonEvent(e); switch (e.GetCallback()) { case RIBBONCALLBACK_ONACTION: if (e.GetId() == _T("Ribbon1_PushButton")) XlMessageBox(_T("Hello from the ribbon!"), XlMessageBoxTypeInformation); break; } return xloResult; }
The table below lists the event parameters and return values for the various callback types.
Callback | Description | Parameters | Return type | Return value |
---|---|---|---|---|
RIBBONCALLBACK_ONACTION | The user has clicked a button or a menu or has selected an item from a gallery or dropdown. | Id, Tag, [Index], [SelectedId], [Pressed] | N/A | N/A |
RIBBONCALLBACK_GETDESCRIPTION | The ribbon is asking for the description of a control. | Id, Tag | String | The description of the specified control. |
RIBBONCALLBACK_GETENABLED | The ribbon is asking for the enabled state of a control. | Id, Tag | Boolean | True if the control is enabled; false if it is not. |
RIBBONCALLBACK_GETIMAGE | The ribbon is asking for the image for a control. | Id, Tag | String | The resource id of an embedd PNG image, or the name of an PNG file in the same directory as the XLL. |
RIBBONCALLBACK_GETIMAGEMSO | The ribbon is asking for the image for a control. | Id, Tag | String | The id of a standard Office image. |
RIBBONCALLBACK_GETLABEL | The ribbon is asking for the label of a control. | Id, Tag | String | The label of the specified control. |
RIBBONCALLBACK_GETKEYTIP | The ribbon is asking for the key tip of a control. | Id, Tag | String | The key tip of the specified control. |
RIBBONCALLBACK_GETSIZE | The ribbon is asking for the size of a control. | Id, Tag | Integer | 0 for a regular sized control; 1 for a large control. |
RIBBONCALLBACK_GETSCREENTIP | The ribbon is asking for the screentip of a control. | Id, Tag | String | The screentip of the specified control. |
RIBBONCALLBACK_GETSUPERTIP | The ribbon is asking for the supertip of a control. | Id, Tag | String | The supertip of the specified control. |
RIBBONCALLBACK_GETVISIBLE | The ribbon is asking whether a control is currently visible. | Id, Tag | Boolean | True if the control is visible; false if it is not. |
RIBBONCALLBACK_GETSHOWIMAGE | The ribbon is asking whether the image of a control should be shown. | Id, Tag | Boolean | True if the image is visible; false if it is not. |
RIBBONCALLBACK_GETSHOWLABEL | The ribbon is asking whether the label of a control should be shown. | Id, Tag | Boolean | True if the label is visible; false if it is not. |
RIBBONCALLBACK_GETPRESSED | The ribbon is asking for the pressed state of a control. | Id, Tag | Boolean | True if the control is pressed; false if it is not. |
RIBBONCALLBACK_GETITEMCOUNT | The ribbon is asking how many items are contained within a control. | Id, Tag | Integer | The number of items in the specfied control. The ribbon will make further callbacks for each item. |
RIBBONCALLBACK_GETITEMHEIGHT | The ribbon is asking for the height of items within a control. | Id, Tag | Integer | The height of each item within a control, in pixels. |
RIBBONCALLBACK_GETITEMID | The ribbon is asking for the id of an item within a control. | Id, Tag, Index | String | The id of the specifed item. |
RIBBONCALLBACK_GETITEMIMAGE | The ribbon is asking for the image of an item within a control. | Id, Tag, Index | String | The resource id of an embedd PNG image, or the name of an PNG file in the same directory as the XLL. |
RIBBONCALLBACK_GETITEMLABEL | The ribbon is asking for the label of an item within a control. | Id, Tag, Index | String | The label of the specified item. |
RIBBONCALLBACK_GETITEMSCREENTIP | The ribbon is asking for the screentip of an item within a control. | Id, Tag, Index | String | The screentip of the specified item. |
RIBBONCALLBACK_GETITEMSUPERTIP | The ribbon is asking for the supertip of an item within a control. | Id, Tag, Index | String | The supertip of the specified item. |
RIBBONCALLBACK_GETITEMWIDTH | The ribbon is asking for the width of an item within a control. | Id, Tag, Index | Integer | The width of the specifed item within a control, in pixels. |
RIBBONCALLBACK_GETTEXT | The ribbon is asking for the current text of the control. | Id, Tag | String | The current text in an editBox or comboBox control. |
RIBBONCALLBACK_ONCHANGE | The ribbon is notifying the add-in that a text field has been changed by the user. | Id, Tag, Text | String | The current text in an editBox or comboBox control. |
RIBBONCALLBACK_GETSELECTEDITEMID | The ribbon is asking for the id of the currently selected item of a control. | Id, Tag | String | The id of the selected item. |
RIBBONCALLBACK_GETSELECTEDITEMINDEX | The ribbon is asking for the index of the currently selected item of a control. | Id, Tag | Integer | The index of the selected item. |
RIBBONCALLBACK_GETCONTENT | The ribbon is asking for the content of a dynamic menu control. | Id, Tag | String | XML markup containing the menu items and buttons. |
RIBBONCALLBACK_GETTITLE | The ribbon is asking for the title of a menu separator. | Id, Tag | String | The title (if any) to be shown on the menu separator. |
Header: xllplus.h
CXllApp Class | CXllApp Methods | The Ribbon (User Guide) | Ribbon reference | RibbonCallbackTypes enumeration