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?
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.

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
cdesignerCommented:
may be you can simply hook F1 and call you help file?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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
abancroftCommented:
Great!
0

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
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.