How to disable context sensitive help in MFC?

by Amer Gerzic 31. May 2007 17:05

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.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

C++ | MFC

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Who is Amer?

Amer Gerzic is senior software developer at Presort Services Inc. and founder of Infinity Software Solutions LLC. For futher information please check LinkedIn profile.

View Amer Gerzic's profile on LinkedIn

Recent comments

Comment RSS

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

© Copyright 2008