Developer Blog
Articles about Using Microsoft Developer Tools

MFC Ribbon Bar Doesn't Implement ID_CONTEXT_HELP

Tuesday, November 25, 2008 2:48 AM by jonwood

Overview

One of the predefined command IDs historically supported by MFC is ID_CONTEXT_HELP. When this command is selected, the mouse pointer changes to an arrow with a question mark and, when you click on a control or window, MFC displays help associated with the item clicked.

However, as of Visual Studio 2008 SP1, this command does not work for the ribbon bar. The command is still implemented but it does not obtain the correct value and so help fails to load.

Details

CMFCToolBar derives from CBasePane, which derives from CWnd. The handler for ID_CONTEXT_HELP ends up calling CBasePane::OnHelpHitTest() to obtain the ID of the element that was clicked. To accomplish this, CBasePane::OnHelpHitTest() calls CWnd::OnToolHitTest(), which is virtual.

Classes like CMFCToolBar override OnToolHitTest() to return the ID of the button at the specified location. But CMFCRibbonBar does not override OnToolHitTest() and so CWnd::OnToolHitTest() tries to find the child window at the specified point. Since ribbon elements are not actual windows, CWnd::OnToolHitTest() finds no child windows and returns -1. As a result, CBasePane::OnHelpHitTest() simply returns the ID of the ribbon window itself, which is useless here.

Resolution

Someone from Microsoft confirmed with me this issue and said it was not supported because it is not supported in the Microsoft Office 2007 applications.

In all fairness, the ribbon bar has a fairly sophisticated tooltip system than can be used to display brief help for any element by simply hovering the mouse over that element. This makes the ID_CONTEXT_HELP command far less important than it may have been in the past. Still, I ended up wasting a bit of time trying to determine why I couldn't get ID_CONTEXT_HELP to work with the ribbon bar. The best fix may simply be to avoid its use in MFC applications that have a ribbon bar.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   C++/MFC
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed