Discussion:
Failed to Launch Help
(too old to reply)
Jonathan Wood
2010-05-07 03:15:09 UTC
Permalink
I created a brand new MFC dialog-based application using Visual Studio 2010.
I chose the option to create context-sensitive help. I can manually open the
CHM file and it looks fine. But when I either hit F1 or click the Help
button (ID_HELP) in my dialog box, I get a message box that says "Failed to
launch help."

After considerable time, I've managed to isolate the routine that is
failing. AfxHtmlHelp() loads hhctrl.ocx and gets the function address for
"HtmlHelpW". Both of these steps are successful. But when it calls
HtmlHelp() via the pointer, 0 is returned. And when that value of 0 is
returned back to CWnd::HtmlHelp(), the "Failed to launch help" message is
displayed.

One thing I didn't quite understand is that the hWnd argument sent to
AfxHtmlHelp() shows in the debugger as "hWnd = 0x00430638 {unused=0 }". As
you can see, it's not NULL but I don't know if the "unused" comment is just
because it's not accessible or what.

Does anyone have any ideas on this? I don't know a whole lot about HTML help
but this is the main dialog box created by the Wizards so I kind of figure
this would work right out of the box. I'm not sure where else to look.

Thanks!
--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Rob Chandler [MVP]
2010-05-07 11:25:44 UTC
Permalink
So you are using the Wide version of HTMLHelp(). So using PWideChar right?

Can you write some standalone test code that calls help ... do you still
have problems?
But when it calls HtmlHelp() via the pointer, 0 is returned. And when that
value of 0 is returned...
Normal the HtmlHelp() call returns a handle to the help window created. But
something
fails so 0 is returned.

I'm coming from Delphi but the calls are the same

HtmlHelp(hwndCaller: HWND; pszFile: PWideChar; uCommand: UInt; dwData:
DWORD): HWND;

hwndCaller can be 0 -- Which I prefer since the help window is not locked
ontop of the main window.

pszFile - Should be a full path to your CHM.


Some examples you should try in a test file...

EG. To open a CHM file

HtmlHelp(GetDesktopWindow, "c:\Help.chm", HH_DISPLAY_TOPIC, 0);

EG. To open a CHM file at a particular Topic

HtmlHelp(GetDesktopWindow, "c:\Help.chm::/Intro.htm", HH_DISPLAY_TOPIC,
0);

EG. To open a CHM file at a particular Topic and use a Window definition
called "Mainwin".

HtmlHelp(GetDesktopWindow, "c:\Help.chm::/Intro.htm>Mainwin",
HH_DISPLAY_TOPIC, 0);

EG. To open a CHM file using context help = 1001

HtmlHelp(GetDesktopWindow, "c:\Help.chm", HH_HELP_CONTEXT, 1001);

EG. Close help

HH.HtmlHelp(0, nil, HH_CLOSE_ALL, 0);

Rob
I created a brand new MFC dialog-based application using Visual Studio
2010. I chose the option to create context-sensitive help. I can manually
open the CHM file and it looks fine. But when I either hit F1 or click the
Help button (ID_HELP) in my dialog box, I get a message box that says
"Failed to launch help."
After considerable time, I've managed to isolate the routine that is
failing. AfxHtmlHelp() loads hhctrl.ocx and gets the function address for
"HtmlHelpW". Both of these steps are successful. But when it calls
HtmlHelp() via the pointer, 0 is returned. And when that value of 0 is
returned back to CWnd::HtmlHelp(), the "Failed to launch help" message is
displayed.
One thing I didn't quite understand is that the hWnd argument sent to
AfxHtmlHelp() shows in the debugger as "hWnd = 0x00430638 {unused=0 }". As
you can see, it's not NULL but I don't know if the "unused" comment is
just because it's not accessible or what.
Does anyone have any ideas on this? I don't know a whole lot about HTML
help but this is the main dialog box created by the Wizards so I kind of
figure this would work right out of the box. I'm not sure where else to
look.
Thanks!
--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Jonathan Wood
2010-05-07 15:13:36 UTC
Permalink
Post by Rob Chandler [MVP]
So you are using the Wide version of HTMLHelp(). So using PWideChar right?
I don't know what PWideChar is. I'm using MFC, TCHARs, with the project set
to use Unicode.
Post by Rob Chandler [MVP]
Can you write some standalone test code that calls help ... do you still
have problems?
My window class has an HtmlHelp() method. When I call it with a topic value
or 0, the help window *does* display. So I guess the function is working and
the error is from having an invalid topic ID. Guess I'll need to dig further
into my help files and see why it's not sending a valid topic ID.
Post by Rob Chandler [MVP]
Normal the HtmlHelp() call returns a handle to the help window created.
But something
fails so 0 is returned.
Yes, I know.

Anyway, that gives me a direction to look further.

Thanks.

Jonathan

Loading...