11.23. How do I add 'What's this' menus to my application - like Win95 hip apps have?

Here's some steps to get you started->

  1. Put the following menu into a resource script:
IDR_WHAT_IS_THIS_MENU     MENU    DISCARDABLE
BEGIN
    BEGIN
        POPUP "a"
        BEGIN
            MENUITEM "What's this?", ID_WHAT_IS_THIS
        END
    END
END
  1. Add to your dialog a right-click handler (OnRButtonDown) with menu IDR_WHAT_IS_THIS_MENU. You need to store the point of the last click in some variable - for example
CPoint m_cLastRClickPoint;
 
and store here the client coordinates of the last right click.
  1. Put the following code into your dialog class (or probably the parent class of all your dialogs):
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
    //{{AFX_MSG_MAP(CMyDialog)
    // whatever
    //}}
    ON_COMMAND(ID_WHAT_IS_THIS, OnWhatIsThis)
END_MESSAGE_MAP()
 
void CMyDialog::OnWhatIsThis()
{
    CWnd* pControl = ChildWindowFromPoint (m_cLastRClickPoint);
   
    // if the click wasn't on one of the controls - open help for dialog
    if (pControl == NULL || pControl->m_hWnd == m_hWnd)
        WinHelp (HID_BASE_RESOURCE + m_nIDHelp, HELP_CONTEXTPOPUP);
    else
        WinHelp (HID_BASE_CONTROL + pControl->GetDlgCtrlID(), HELP_CONTEXTPOPUP);
}
 
- and finally add the following lines to the makehelp.bat file:
 
echo. >>hlp\wr.hm
echo // Controls (IDC_*) >>hlp\wr.hm
makehm IDC_,HIDC_,0x50000 resource.h >>hlp\wr.hm

This wires everything to your help system.

Poul A. Costinsky (PoulACost@msn.com).