How can i catch the help button "?" message in a MFC dialog

Posted on 2008-11-06
Last Modified: 2013-11-20

After googling all day, I thought i would post it here.
I have a MFC application in which i want to integrate a compiled help file.
with few links i could do it.
however on a CDialog-derived dialog, when I add Context help i am able to see "?" in the title.
when i click on ?, the cursor will have a ? and only when i click on a control my OnHelpInfo function is called.
What i want is:- when user clicks ont the "?" button, I want to directly open the chm file.

I cant seem to find a function where i can call htmlhelp.
I have tried OnHelp() but that will only be called when F1 is pressed, but not when ? is clicked.

Can anyone tell me how can i do this?
Question by:LearningCpp
    LVL 30

    Accepted Solution

    Hi LearningCpp,

    just add a WM_SYSCOMMAND message handler in the dialog - implement it like this:

    void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
          if ( nID == SC_CONTEXTHELP )
                AfxMessageBox( "Show help here ..." );

          CDialog::OnSysCommand(nID, lParam);

    Hope that helps,

    LVL 39

    Expert Comment

    >>>> only be called when F1 is pressed, but not when ? is clicked.
    The ? minibutton is a context help which was supposed to give help for an item like an edit field or list control where the user clicked on using the ? cursor.

    You could integrate the normal help into a help menu by adding a menu item with the ID_HELP id. You also could add a new minibutton for the standard help by enhancing the toolbar buttons in CMainFrame class. Check the mainframe.cpp for that.

    Author Comment

    Experts Rock!!
    LVL 49

    Expert Comment

    I concur  with itsme... The [?] button is a U/I device that has a specific purpose:  context-sensitive help for individual U/I elements on a form.   I'd never use it as a way to get general help, any more than I'd change the meaning the the [x] button to mean "delete the last thing I typed" or "turn the window green."   One should not confuse the user by making novel use of system-defined U/I elements.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now