How to disable context sensitive help in MFC?

May 31, 2007 at 5:05 PMAmer Gerzic

Couple of days ago, I worked on an MFC application that required special functionallity of F1 key. At first, I thought that all I need is to override application's PreTranslateMessage function and trap the F1 key. However, I was wrong. Every time I pressed F1 key, the application performed custom function, but also popped message box saying that help file could not be located. My first thought was that MFC/Windows is placing a windows hook to trap such functionality and that the workaround might not be very elegant. Fortunatly that was not the case. After some investigation, I noticed the following code:

BEGIN_MESSAGE_MAP(CDRSApp, CWinApp)
    ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()

In other words, main application is getting notification to handle help request and is passing it to default MFC implementation. Once the ON_COMMAND line is commented out, such hadling is disabled.

Posted in: CPP | MFC

Tags: , , ,