Implementing ToolTip Style Context Sensitive Help in CFormView based Applications

 Download Source Code and Example

Steps Required

1. In your form view or in the dialogs you are working with, turn "Help ID" property on for every control you want to have context sensitive help.

2. #define a double word Array in your View class as

static const DWORD m_nHelpIDs[];

and in your Implementation do the following:

const DWORD COurView::m_nHelpIDs[] = 

In our case declaration of help IDs array is as

static const DWORD m_nHelpIDs[];

and these IDs are defined as

const DWORD CCSHView::m_nHelpIDs[] = 

	//define other controls IDs here.


3. Include file in your View.CPP file.

4. Open your application's HPJ (help project file) and add the following line at the end of the file

#include <D:\Development\CSH\>

The path will differ according to the location of your project.

5. Now override two functions of your CFormView based class. One is WM_CONTEXTMENU and other is WM_HELPINFO.

Fill the functions' bodies as follows.

// CCSHView message handlers

void CCSHView::OnContextMenu(CWnd* pWnd, CPoint point)
	::WinHelp(pWnd->m_hWnd, AfxGetApp()->m_pszHelpFilePath, HELP_CONTEXTMENU,

} BOOL CCSHView::OnHelpInfo(HELPINFO* pHelpInfo) { return ::WinHelp((HWND)pHelpInfo->hItemHandle, AfxGetApp()->m_pszHelpFilePath, HELP_WM_HELP, (DWORD)(LPVOID)m_nHelpIDs); }

6. Now Open Microsoft Word (or any other RTF word processor) "AfxCore.RTF" file located in your projects HLP directory. This file was generated by Application Wizard.

7. In Tools menu click Options and then highlight "View" tab. Then turn "Hidden Text" check box on which is in the group "Non Printing characters". Now Click "Show/Hide" button

8. Now navigate to the end of file and press Ctrl + Enter to enter a hard page break.

9. Type help text here for the first control. In our case it is IDC_BUTTON_HELP. We type "Displays detailed help for the application" here.

10. Now go to beginning of the line and insert a footnote with a custom mark "#" and in the footnote type HIDC_BUTTON_HELP here. Click in the view window again.

11. Now to see a question mark icon in the title bar of the application go to your application's CMainFrame class's add the following lines in your CMainFrame::PreCreateWindow(..) function = WS_OVERLAPPED | WS_CAPTION |FWS_ADDTOTITLE
	cs.dwExStyle |= WS_EX_CONTEXTHELP;

If you turn WS_MINIMIZE AND WS_MAXIMIZE on then question mark icon will not appear in the title bar.

12. Bingo. We are done. Compile the project and see the online context sensitive help in action. Press Shift + F1 key when the focus is on the "Help" button in the form view and see a little tooltip style window containing the help you wrote. Here is how it will look like

Where now?

The next article explores how to implement ToolTip style context sensitive help in a dialog.

Last updated: 24 April 1998


  • ToolTip - Context Sensitive Help - I'm impressed

    Posted by Legacy on 03/13/2000 12:00am

    Originally posted by: Vince

    I must say, this is the most impressive context sensitive help method I have seen so far. All other ones I have read in the past attempt to use HTMLHELP with H_CONTROL and so forth...after following other methods which require tyou to download various files from the net and embed a heap of code, I was deterred each time.

    This method, on the other hand, is about as easy as it gets. Contrary to the other comment to this topic, I found the code provided to work perfectly in a CFormView app. I shall recommend this to other colleagues and I suggest you don't waist yourt time attempting to learn other lengthly methods which often result in dissapointment.

  • Implementing ToolTip Style Context Sensitive Help in CFormView based Applications

    Posted by Legacy on 01/26/1999 12:00am

    Originally posted by: K. Faidt

    With Visual Studio 6.0, NT 4.0, the sample code provided with this page did not work. Setting a breakpoint in CCSHView::OnHelpInfo, the windows help window appeared displaying the contents page before entering the breakpoint.
    Stepping over the call of WinHelp, an additional popup appeared telling that the help topic wasn't found.

    The help with the "sample dialog" (as described in the next page) did work: The correct popups did appear without showing the windows help window before.

    1. Rebuild csh.hlp after inserting help topics for the controls of the view. The help topics weren't found because they were not present in the help file.
    2. To avoid displaying the WINDOWS help window, I mapped the MFC-internal message WM_COMMANDHELP to method OnCommandHelp (a method of the view class). That method only returns true. An alternative way would be to call WinHelp in that method and omit handling of WM_HELPINFO.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds