Activate HELP button on propertysheet?

I have a 6-tab property sheet in my app.  I have turned on the Help button at the bottom, but cannot figure out how to connect the button to my help file.

I've tried ClassWizard to add functions for WinHelp, WM_HELPINFO, and ID_CONTEXT_HELP in both the propertysheet class and the individual property pages.  I put breaks in those functions and compile/run, but the functions are not being called when I click the Help button.  All I get is the message box that "the Help topic could not be found; contact vendor......"

Help?  (pun intended)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have a user defined message say WM_HELPDISP in view class.
#define WM_HELPDISP  WM_USER+100
Map the user defined message in the view class
afx_msg LRESULT OnHelpDisplay(WPARAM wparam, LPARAM lparam);

Map the user defined function


In the Function
LRESULT OnHelpDisplay(WPARAM wparam, LPARAM lparam)
  call WinHelp(................);

Now for each page map the Help  button
In that function call

Hope this helps

A solution for the Help.

afx_msg void OnHelp();
afx_msg LRESULT OnCommandHelp(WPARAM, LPARAM);

BEGIN_MESSAGE_MAP(CSheet, CPropertySheet)

void CSheet::OnHelp()
// for the "Help" button

LRESULT CSheet::OnCommandHelp(WPARAM wParam, LPARAM lParam)
  // for context help
  HELPINFO *pHelpInfo = (HELPINFO*)lParam;
  UINT nID = pHelpInfo->iCtrlId;
  switch (nID)
      CPage *pPage = (CPage*)GetActivePage();
      nID = HID_BASE_RESOURCE + pPage->GetHelpID();
      uCommand = HELP_CONTEXT;
    case IDOK:
    case IDCANCEL:
    case ID_APPLY_NOW:
    case ID_HELP:
      uCommand = HELP_CONTEXT;
  theApp.WinHelp(nID, uCommand);
  return 0;

It work fine.
regards, jean-claude.
When the user clicks on Help, the property sheet sends the PSN_HELP notification. That is when you should display your help topic.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

SixStringAuthor Commented:
I think Luisr is on the track I'm looking for.

I added this to my propertypage function (it's from the MFC 4.0 help):

BOOL CPhaseVehicleDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  switch (((NMHDR*) lParam)->code)
    case PSN_HELP:
      WinHelp (((NMHDR*) lParam)->hwndFrom, "WinTAP.HLP", HELP_CONTEXT,  HIDD_PHASE_VEHICLE);
  return CPropertyPage::OnNotify(wParam, lParam, pResult);

I get a compile error "WinHelpA: function does not take 4 parameters."

If I comment the WinHelp line, I can compile/run and did verify that this is getting called when I click "Help."  Now I just need to connect it to my help file.

What is this WinHelpA error about?

Use ::WinHelp. Otherwise, the compiler thinks you are using CWnd::WinHelp.
Before calling DoModal() do the following

      CSheet dlg("Enable Help");
      dlg.m_psh.dwFlags |= PSH_HASHELP ;

In the constructor of CSheet class
do the following each page
      m_page1.m_psp.dwFlags |=PSP_HASHELP ;

In The OnCommand() of Property sheet class
BOOL CSheet::OnCommand(WPARAM wParam, LPARAM lParam)
      UINT nID = LOWORD(wParam);
      if(nID == IDHELP)
      OnHelpDisplay(wParam, lParam);
return CPropertySheet::OnCommand(wParam, lParam);
where OnHelpDisplay(.....) is a user defined message

In the user defined message do the following
LRESULT CSheet::OnHelpDisplay(WPARAM wparam, LPARAM lparam)
::WinHelp(m_hWnd,"MyHelp.hlp",HELP_CONTENTS ,0);
      return 0;
this will display the help

He already can display the Help button, he just did not know how to repond to it. I think my previous comment along with chensu's helped him with his problem.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SixStringAuthor Commented:
Yes, thanks to luisr + chensu I have the Help file coming up.  It is still not going to the proper location.  I get it to come up via:

::WinHelp (((NMHDR*) lParam)->hwndFrom, "WinTAP.HLP", HELP_CONTENTS, 0x0);

I checked the .hm file the complier built for me, and it has the following line

HIDD_PHASE_VEHICLE                      0x20099

This is the appropriate dialog for the Help button to invoke.  When I put that value in, however,

::WinHelp (((NMHDR*) lParam)->hwndFrom, "WinTAP.HLP", HELP_CONTEXT, 0x20099);

I get the ol' "Topic not found."  This is probably due to my lack of understanding about help file construction under MFC.  The topic ID for that page in the RTF file is "phase_vehicle."  I tried adding an identifier for that in the .hm file:

phase_vehicle           0x21000

and using that value, but it didn't work.

Any advice (or a URL to a good WinHelp tutorial that would have the answer)?


SixStringAuthor Commented:
I would like to give a few of the points to chensu, but I don't know if that's possible.  Sorry.  :)
SixStringAuthor Commented:
Disregard previous comment.  It turns out

1)  My ID must be in the Dialog section of the .hm file, and

2)  I needed a

return FALSE;

statement after handling the PSN_HELP message.

Thanks, all!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.