views:

646

answers:

1

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!

+1  A: 

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);
demoncodemonkey