WinHelp in C++

Hello
I want to use WinHelp in a MFC application. I work with Visual Studio 2003.

I did already following:

// CUiApp Konstruktion
CUiApp::CUiApp()
{
  EnableHtmlHelp();
      // ZU ERLEDIGEN: Hier Code zur Konstruktion einfügen
      // Alle wichtigen Initialisierungen in InitInstance platzieren
}

When I call the Help, I call

  "ON_COMMAND(ID_HELP, CWinApp::OnHelp)"

the program jumps to apphelpx.cpp
void CWinApp::OnHelp()  // use context to derive help context
{
      if (m_dwPromptContext != 0)
      {
            // do not call WinHelp when the error is failing to lauch help
            if (m_dwPromptContext != ID_BASE_PROMPT+AFX_IDP_FAILED_TO_LAUNCH_HELP)
                  WinHelpInternal(m_dwPromptContext);
            return;
      }

      // otherwise, use CWnd::OnHelp implementation
      CWnd* pWnd = AfxGetMainWnd();
      ASSERT_VALID(pWnd);
      if (!pWnd->IsFrameWnd())
            pWnd->OnHelp();
      else
            ((CFrameWnd*)pWnd)->OnHelp();
}


at "pWnd->OnHelp();" the programm jumps to winfrmx.cpp
void CWnd::OnHelp()  // use context to derive help context
{
      // attempt to get help from whoever is tracking
      HWND hWnd = ::GetCapture();
      while (hWnd != NULL)
      {
            // attempt to process help
            if (::SendMessage(hWnd, WM_COMMANDHELP, 0, 0))
                  return;

            // check next parent/owner in the parent/owner chain
            hWnd = AfxGetParentOwner(hWnd);
      }
      // attempt to get help from whoever has the focus
      hWnd = ::GetFocus();
      while (hWnd != NULL)
      {
            // attempt to process help
            if (::SendMessage(hWnd, WM_COMMANDHELP, 0, 0))
                  return;

            // check next parent/owner in the parent/owner chain
            hWnd = AfxGetParentOwner(hWnd);
      }


when the program is at " if (::SendMessage(hWnd, WM_COMMANDHELP, 0, 0))" it opens an error window with the message "Failed to launch help."


What can I do??
ICSAutomationAsked:
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.

AndyAinscowFreelance programmer / ConsultantCommented:
Does the help file exist?  (check the directory the exe file is in)




>>I want to use WinHelp in a MFC application.
 >>EnableHtmlHelp();

Which do you want to use?  Winhelp or HTML based help, they are not the same.
0
lucky_jamesCommented:
please correct your zone.....you should have included c++ programming language.

Also ensure that you are not calling OnHelp twice. I have noticed couple of time this error being thrown by such multiple calls as well.

check out:
http://www.experts-exchange.com/Programming/Languages/CPP/Q_22541662.html
http://www.codeguru.com/forum/archive/index.php/t-462471.html
0
MikeAThonCommented:
WinHelp (which uses .hlp files) is different from HTMLHelp (which uses .chm files).
WinHelp is way old.  MFC for VS 2003 probably doesn't even support it.  In fact, as of Vista, Microsoft doesn't even ship the WinHelp help engine (i.e., doesn't ship WinHlp32.exe).  See "I cannot open Help files that require the Windows Help (WinHlp32.exe) program" at http://support.microsoft.com/kb/917607/en-us 
Are you certain that you want to use WinHelp, as stated in your OP?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ICSAutomationAuthor Commented:
Actually I want to use a HtmlHelp (*.chm). That's way I put
>>EnableHtmlHelp();
0
AndyAinscowFreelance programmer / ConsultantCommented:
Did you check if the help file exists?
0
ICSAutomationAuthor Commented:
Sorry for writing "WinHelp" in my question. What I want to open is a HtmlHelp (*.chm) file.

Thanks for the links. I was through these already before. I found them with googeling a little bit...

I need a suggestion what I do wrong in my code. I there a parameter I have to set?
Has anybody an idea?

0
ICSAutomationAuthor Commented:
The help file exists, but I had it in the wrong folder :-(  *stupid*
Thanks for this comment!
But now I get another error message:
HH_HELP_CONTEXT called without a [MAP] section.

What is this?
 
0
help-infoCommented:
Please see:
http://www.codeguru.com/cpp/w-p/help/html/article.php/c6513 search for e.g. [MAP]
and
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_context-id.htm

Best regards
Ulrich Kulle
************************
Microsoft Help MVP 2007-2009
www.help-info.de
************************
0
AndyAinscowFreelance programmer / ConsultantCommented:
>>The help file exists, but I had it in the wrong folder

That is what I suspected was the problem.


MAP sections - when you try to use context help (eg. help specific to button 'do this') the app calls the help program with the ID of the button, the help then looks in the map section to find what help needs to  be shown by mapping the ID from the app to the ID of the help section when you authored it.  The error message should be self explanatory.
0
ICSAutomationAuthor Commented:
ok, I understand that I have to MAP my HtmlHelp. I checked the links, but didn't really understand. I have to do something in the folder of the HtmlHelp and also in the C++ application. What I ahve to do where?

To get the right HelpFile, I added:
CUiApp::CUiApp()
{
  EnableHtmlHelp();
  m_pszHelpFilePath = _tcsdup(_T("D:\\Anlagen\\Gsl1_ml\\PCS\\LsProg\\Ui\\HelpHTML\\LShelp.chm"));
}
Is this correct?
0
ICSAutomationAuthor Commented:
All right. I did the maping in the HtmlHelp. (*.hhp)

[ALIAS]
IDH_90000 = ICS\PCS_UserManual.htm

[MAP]
#define IDH_90000 90000

--> Now I don't get the error " HH_HELP_CONTEXT called without a [MAP] " anymore! :-)

But I still get the message "Failed to launch help."  :-(
What could still be wrong?

Do I have to add the number 90000 in th C++ code? Where I have to add it?

0
help-infoCommented:
Plaese see also deep MFC - CHM info at:
http://www.smountain.com/resource/CPPHTMLHelp.pdf

I'm not a C++ programmer but since VS 2005 I'm using helpProvider with Visual Basic. Some code testing with Visual Studio 2008 und C++ see attachment.

Best regards
Ulrich Kulle
************************
Microsoft Help MVP 2007-2009
************************

// 
// helpProvider1
// 
this->helpProvider1->HelpNamespace = L"C:\\Users\\Ulli\\Documents\\Visual Studio 2008\\Projects\\CPlusPlusCHM\\CHM-example.chm";

using the ShowHelp like:
private: System::Void btnHelp_Click(System::Object^  sender, System::EventArgs^  e) {
  System::Windows::Forms::Help::ShowHelp(this, helpProvider1->HelpNamespace);
  }

Open in new window

0
AndyAinscowFreelance programmer / ConsultantCommented:
@help-info
That is C++.net - which is quite different than MFC (which is unmanaged)
0
ICSAutomationAuthor Commented:
I still don't have it working.
I decided to open a normal pdf File (with ShellExecute(...)) as helpfile.

I'll close this question.

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.

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.