How to handle F1 or help in application?

17 08 2008


Help is inevitable part of every windows application. The first function key – F1 itself is assigned as help in every application. Well, how to handle the user’s “Mayday” call in application?


Basically you’ve to handle the WM_HELP message. When you press F1 the WM_HELP message will be posted to your window. To handle this via MFC, Add ON_WM_HELPINFO() to message map and implement OnHelpInfo() in your dialog. Have a look at the following code snippet.

// Add ON_WM_HELPINFO() to your message map.
BEGIN_MESSAGE_MAP(CYourDialog, CDialog)
   ...
   ON_WM_HELPINFO()
END_MESSAGE_MAP()

// Add this function to your dialog.
BOOL CYourDialog::OnHelpInfo( HELPINFO* HelpInfo)
{
   // Handle your help request here.
   return TRUE;
}


Well, the only help i used to use is MSDN. If I accidentally launch Windows help, I’ll kill it immediately by using taskmgr. I don’t know why I hate it. 🙂


Targeted Audience – Beginners.

Advertisements