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)
SixStringAsked:
Who is Participating?
 
luisrCommented:
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.
0
 
bhatCommented:
Hi
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

ON_MESSAGE(WM_HELPDISP,OnHelpDisplay)

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

Now for each page map the Help  button
In that function call
PostMessage(WM_HELPDISP);

Hope this helps


0
 
jclanzCommented:
Hello,
A solution for the Help.

..H
//{{AFX_MSG(CSheet)
//}}AFX_MSG
afx_msg void OnHelp();
afx_msg LRESULT OnCommandHelp(WPARAM, LPARAM);

..CPP
BEGIN_MESSAGE_MAP(CSheet, CPropertySheet)
//{{AFX_MSG_MAP(CSheet)
//}}AFX_MSG_MAP
ON_COMMAND(ID_HELP, OnHelp)
ON_MESSAGE(WM_HELP, OnCommandHelp)
END_MESSAGE_MAP()

void CSheet::OnHelp()
{
// for the "Help" button
theApp.WinHelp(HID_BASE_RESOURCE + IDD_PROPERTY_DIALOG, HELP_CONTEXT);
}

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

It work fine.
regards, jean-claude.
jclanz@bluewin.ch
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
luisrCommented:
When the user clicks on Help, the property sheet sends the PSN_HELP notification. That is when you should display your help topic.
0
 
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);
      break;
    }
  }
  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?

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

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

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

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

0
 
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)?

Thanks.


0
 
SixStringAuthor Commented:
I would like to give a few of the points to chensu, but I don't know if that's possible.  Sorry.  :)
0
 
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.