Question

I have a CMFCRibbonStatusBar in my mainframe to which I add a CMFCRibbonButtonsGroup which again has a CMFCRibbonButton. This button has the same ID as a menu entry.

Creating the button is done as follows:

CMFCRibbonButtonsGroup* pBGroup = new CMFCRibbonButtonsGroup();

CMFCToolBarImages images;
images.SetImageSize(CSize(32, 16)); // Non-square bitmaps
if(images.Load(IDB_STATUSBAR_IMAGES))
{
    pBGroup->SetImages(&images, NULL, NULL);
}

m_pStatusButton = new CMFCRibbonButton(ID_STATUS_SHOWSTATUS,
                                       _T(""),
                                       IMAGEINDEX_DEFAULTSTATUS);

pBGroup->AddButton(m_pStatusButton);

m_wndStatusBar.AddExtendedElement(pBGroup, _T(""));

I want to use this button as a status indicator.

I want to display a tool tip in the following two cases:

  • when the status changes and
  • when the user moves the mouse over the button.

I have no idea how to start in the first place. I have looked at the ToolTipDemo and DlgToolTips sample projects but couldn't figure out how to do it since all they do is display tooltips for the toolbar items or dialog buttons (CWnd-derived instead of CMFCRibbonButton).

If you are familiar with the ToolTipDemo sample project: Since there seem to be several ways of doing things, I would prefer the tooltip to look like the "Extended Visual Manager-based" tool tip as shown in this screenshot.

Thanks!

Was it helpful?

Solution

I don't think it's possible to show the tooltip without the mouse cursor being over the control. That's all done automatically.

However if you want to have a nice looking tooltip like in your screenshot, you need to call SetToolTipText and SetDescription, like this:

CMFCRibbonButton* pBtn = new CMFCRibbonButton(12345, _T(""), 1);
pBtn->SetToolTipText("This is the bold Title");
pBtn->SetDescription("This is the not-so-bold Description");
pGroup->AddButton(pBtn);

OTHER TIPS

I am using CMFCRibbonButton controls within a CMFCRibbonButtonGroup, which is added to the CMFCRibbonStatusBar. Take note of the 4th parameter in the CMFCRibbonButton() constructor, bAlwaysShowDescription, as this seems to affect the behavior depending upon whether SetDescription() has been called.

Specifically, if SetDescription() has not been called, it doesn't matter whether bAlwaysShowDescription is TRUE or FALSE - the tool tip is displayed (as I would expect). If SetDescription() is set and bAlwaysShowDescription is FALSE, when hovering over the button the tool tip is displayed with the description below it.

What seems counterintuitive given the name of this bAlwaysShowDescription parameter, is that when this is TRUE and SetDescription() is set, NEITHER the tool tip nor the description appear. I wonder if this is related to this post: https://connect.microsoft.com/VisualStudio/feedback/details/399646/cmfcribbonbutton-wont-show-tooltip-if-balwaysshowdescription-1

Hope this helps and you can achieve what you need with the different combinations of bAlwaysShowDescription parameter and whether SetDescription() is set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top