How to handle the Help button on CMFCPropertySheet / CMFCPropertyPage?

132 views Asked by At

According to MSDN:

Help in CPropertySheet is supported by the F1 key and the Help button only. The Help button appears in the application framework by default. No intervention by the user is necessary. When the user adds the help information for each of the pages inside the property sheet, the help mechanism automatically displays the help for that page when the Help button is clicked.

I assume the same to be true for CMFCPropertySheet. So I first started to try handling the WM_HELPINFO handler:

void COtherSettingsEmailInfoPage::HtmlHelp(DWORD_PTR dwData, UINT nCmd)
{
    HtmlHelp((DWORD_PTR)_T("HelpOptionsEmail.html"), HH_DISPLAY_TOPIC);

    //CMFCPropertyPage::HtmlHelp(dwData, nCmd);
}

Didn't work. Then I added a IDHELP button click handler:

void COtherSettingsEmailInfoPage::OnHelp()
{
    HtmlHelp((DWORD_PTR)_T("HelpOptionsEmail.html"), HH_DISPLAY_TOPIC);
}

Didn't work.

So how am I supposed to show the right help topic when the user presses the Help button on the sheet? Confused.

Update

I have tried this in both the sheet and the page - doesn't work:

BOOL COtherSettingsEmailInfoPage::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
    LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;

    if (lppsn->hdr.code == PSN_HELP)
    {
        AfxMessageBox(_T("Boo2"));
    }

    return CMFCPropertyPage::OnNotify(wParam, lParam, pResult);
}
1

There are 1 answers

0
Andrew Truckle On BEST ANSWER

Got this sussed out in the end.

Firstly, OI had a small issue with my application where the CWinApp was using the wrong file name. This was caused when I made changes to my application. So I fixed that in InitInstance:

CString strHelp = GetProgramPath();
strHelp += _T("MeetSchedAssist.CHM");
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath = _tcsdup(strHelp);

Next, I had to add a notification handler to the CMFCPropertySheet class:

Header:

afx_msg void OnPsnHelp(NMHDR* hdr, LRESULT* res);   // Our help button message handler

Source:

ON_NOTIFY(PSN_HELP, 0, &COtherSettingsEmailInfoPage::OnPsnHelp)

...
...

void COtherSettingsEmailInfoPage::OnPsnHelp(NMHDR* hdr, LRESULT* res)
{
    HtmlHelp((DWORD_PTR)_T("HelpOptionsEmail.htm"), HH_DISPLAY_TOPIC);
}

Now it correctly shows the help topic.