Context Sensitive Help

I want to be able to change the ID of the help that is displayed after selecting a button that has the ID_CONTEXT_HELP id.  The default MFC routine for this just grabs your EXE name and path and calls it asking for the help for the ID of the control that you pressed.  I know that I can change the help file name quite easily by setting m_pszHelpFilePath, but I can't seem to trap the call to WinHelp.  I have tried overriding the OnCommandHelp routine as described in the MFC Tech Note 28 but it does not work, the routine is never called. Anyone know what I am doing wrong?

I would also like to know how to change the ID of the button that instigates context sensitive help, if I change the ID it does not work anymore!

Thanks.
LVL 2
r parkinsonAsked:
Who is Participating?
 
abancroftConnect With a Mentor Commented:
Great!
0
 
cdesignerCommented:
add handler for WM_HELPINFO in Class wizard.

OnHelpInfo(HELPINFO* pHelpInfo)
{

CDialog::OnHelpInfo(pHelpInfo);
}

look the HELPINFO structure
0
 
r parkinsonAuthor Commented:
More information please.

My App is not a standard MFC app, it has several windows that appear as the mainframe.  It started off as a C app which was ported to MFC so it's quite a complex inntegration with MFC. I have tried in a simple MFC app and the OnHelpInfo routine does not get called.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
cdesignerCommented:
may be you can simply hook F1 and call you help file?
0
 
r parkinsonAuthor Commented:
After the ID_CONTEXT_HELP button is pressed and I get the pointer with the '?'  I cant get any command message untill after the mouse has been clicked again.  Any other sugestions, or shall I reject the answer to let someone else have a go.
0
 
cdesignerCommented:
ok
I dont know now other way
0
 
abancroftCommented:
Override CWinApp::WinHelp(). Do you processing (i.e. change the help id) and then call base class WinHelp() function (i.e. the original CWinApp version).

i.e.

void CYourApp::WinHelp(DWORD dwData, UINT nCmd)
{  
  if (nCmd==HELP_CONTEXT)
    dwData = <Whatever you want>

  CWinApp::WinHelp(dwData, nCmd);
}
0
 
r parkinsonAuthor Commented:
abancroft

When I add the WinHelp Override I get an error on the line

CWinApp::WinHelp(dwData,nCmd);

ganttfrm.cpp(800) : error C2352: 'CWinApp::WinHelpA' : illegal call of non-static member function

Is this a clue as to what I am doing wrong?

In my app if I comment out the line that causes the error then the WinHelp routine never gets called, however in the scribble example I can do exactly the same thing and it works fine.
0
 
abancroftCommented:
Paste the declaration & definition for your WinHelp() override.
0
 
r parkinsonAuthor Commented:
declaration :

 virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);

definition :

void CSequencerFrame::WinHelp(DWORD dwData, UINT nCmd)
{
  // Beep to let me know its in the routine
  if (nCmd==HELP_CONTEXT)
    MessageBeep(0xFFFFFFFF);

  CWinApp::WinHelp(dwData, nCmd);
}
0
 
abancroftCommented:
You have not overridden CWinApp version - you have added a new function to your frame window (I'm assuming CSequencerFrame is derived from CFrameWnd.

You need to overide in your CWinApp derived class.

0
 
r parkinsonAuthor Commented:
Ah!  Now I am getting somwhere, but not quite all the way!

I can now get my App to enter the WinHelp routine, but I can't add the CWinApp::WinHelp line to actually get the help! I get the C2352 error described previously.
0
 
abancroftCommented:
And is CWinApp a base class of CSequencerFrame?
0
 
r parkinsonAuthor Commented:
Oops, no its not!

I have done it correctly now and it all works, answer the question and I'll give you the points.
0
All Courses

From novice to tech pro — start learning today.