Link to home
Start Free TrialLog in
Avatar of ICSAutomation
ICSAutomationFlag for Switzerland

asked on

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??
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

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.
SOLUTION
Avatar of lucky_james
lucky_james
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ICSAutomation

ASKER

Actually I want to use a HtmlHelp (*.chm). That's way I put
>>EnableHtmlHelp();
Did you check if the help file exists?
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?

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?
 
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
************************
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@help-info
That is C++.net - which is quite different than MFC (which is unmanaged)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial