The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: raymond on July 08, 2009, 03:51:17 AM

Title: HtmlHelp function
Post by: raymond on July 08, 2009, 03:51:17 AM
.hlp files are no longer supported by Vista  and other future Windows versions, and either .html or its compiled .chm version is directly supported.

The previously used API to use the .hlp type was WinHelp but it doesn't care about .chm files. It would seem that the HtmlHelp function is the one to be used. Although an .inc and a .lib files are supplied in the MASM32 package, I got a message that the htmlhelp.dll could not be found on my system when I tried to use those in a program.

Furthermore, although I know approximately what is required as parameters, I haven't been able to find the exact requirements and constants of that function to provide context help in a program.

The htmlhelp keyword returns nothing on this forum. Searching the MS SDK has not been successful either to find specific information.

Any hint would be welcomed.
Title: Re: HtmlHelp function
Post by: dedndave on July 08, 2009, 04:10:30 AM
http://www.microsoft.com/downloads/details.aspx?familyid=6EBCFAD9-D3F5-4365-8070-334CD175D4BB&displaylang=en
http://support.microsoft.com/kb/917607
http://www.help-info.de/en/Help_Info_AP_Help/ap_help_vista_support.htm
Title: Re: HtmlHelp function
Post by: sinsi on July 08, 2009, 04:53:32 AM
Microsoft HTML Help 1.4 SDK  (http://msdn.microsoft.com/en-us/library/ms670169(VS.85).aspx)
Title: Re: HtmlHelp function
Post by: ToutEnMasm on July 08, 2009, 05:56:47 AM
Html help workshop
http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc&displaylang=en
I couldn't download the Html 1.4 SDK
The html help libraries given by the masm32 package is too old and the one of the windows sdk  made errors at link time.
The only one who works is the one of the html help workshop.


Title: Re: HtmlHelp function
Post by: jj2007 on July 08, 2009, 09:13:21 AM
Quote from: raymond on July 08, 2009, 03:51:17 AM
The htmlhelp keyword returns nothing on this forum.

Raymond,
Try again. The search function of this forum has a somewhat erratic behaviour, often it responds with zero results but when you try again, several pages pop up. Donkey has invested a lot of efforts in this. My own attempts failed more or less, see snippet below.


include \masm32\include\htmlhelp.inc
includelib \masm32\RichMasm\Help\htmlhelp.lib

LOCAL hq:HH_FTS_QUERY

   .if eax==mtxt(".hlp")
      invoke WinHelp, hWnd, esi, HELP_PARTIALKEY, edi
   .else ; if extension=html
      m2m hq.cbStruct, sizeof hq
      and hq.fUniCodeStrings, 0
      mov hq.pszSearchQuery, edi
      and hq.iProximity, 0
      and hq.fStemmedSearch, 0
      and hq.fTitleOnly, 0
      and hq.fExecute, TRUE
      m2m hq.pszWindow, hWnd
      invoke HtmlHelp, hWnd, esi, HH_DISPLAY_SEARCH, addr hq   ; MSDN (http://msdn.microsoft.com/en-us/library/ms670172.aspx)
   .endif
Title: Re: HtmlHelp function
Post by: dedndave on July 08, 2009, 11:05:24 AM
how strange

when i go to the version 1 d/l page, the text reads:

"This download contains the redistributable files for HTML Help version 1.3"
http://www.microsoft.com/downloads/details.aspx?FamilyID=2363a6fc-cb70-464d-85e6-f598c11ccecf&displaylang=en

the msdn pages for both "html help sdk 1.4" and "windows vista help sdk" tell about the features, but fail to provide d/l links - lol

after poking around a bit, i came up with this link
it is for the "Microsoft Windows Software Development Kit Update for Windows Vista"
this may provide what you need
http://www.microsoft.com/downloads/details.aspx?familyid=4377F86D-C913-4B5C-B87E-EF72E5B4E065&displaylang=en

Title: Re: HtmlHelp function
Post by: jj2007 on July 08, 2009, 09:06:20 PM
The good news is I got it working. The other news is it's crap, Microsoft! You discovered 8 years ago that HH_DISPLAY_SEARCH "does not actually perform a search" (http://support.microsoft.com/kb/241381), and you still haven't fixed it?? The HtmlHelp.lib downloaded today from our friends in Redmond (http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc&DisplayLang=en&displaylang=en#filelist) dates May 2000... holy cow :dazzled:

Quote.if eax==mtxt(".hlp")         ; eax=extension of help file
               invoke WinHelp, hWnd, esi, HELP_PARTIALKEY, edi   ; edi points to current selected text
            .else
               if 1
                  invoke HtmlHelp, hWnd, esi, HH_DISPLAY_INDEX, 0
                  invoke FindWindowEx, eax, 0, chr$("HH Child"), 0
                  .Repeat
                     mov hHH, eax
                     invoke GetWindow, hHH, GW_HWNDNEXT
                  .Until eax==0      ; last window
                  invoke FindWindowEx, hHH, 0, chr$("Edit"), 0
                  .if eax
                     sm eax, WM_SETTEXT, 0, edi   ; edit window found, set search text
                  .else
                     invoke lstrcat, edi, chr$(".html")   ; if you are really lucky, it's a topic
                     invoke HtmlHelp, hWnd, esi, HH_DISPLAY_TOPIC, edi
                  .endif
               else   ; M$ says broken, see here (http://www.help-info.de/en/Help_Info_HTMLHelp/hh_api.htm)
;               deb 1, "Test1", esi$, edi$
;               invoke lstrcat, edi, chr$(".html")
;               m2m hq.cbStruct, sizeof hq
;               and hq.fUniCodeStrings, 0
;               mov hq.pszSearchQuery, edi
;               and hq.iProximity, 0
;               and hq.fStemmedSearch, 0
;               and hq.fTitleOnly, 0
;               m2m hq.fExecute, TRUE
;               m2m hq.pszWindow, offset Null$   ; chr$("ArgCL") ; hWnd
               invoke HtmlHelp, hWnd, esi, HH_DISPLAY_SEARCH, addr hq   ; MSDN (http://msdn.microsoft.com/en-us/library/ms670172.aspx)
               endif
            .endif
Title: Re: HtmlHelp function
Post by: dedndave on July 08, 2009, 10:05:04 PM
MS official posture on Help:
"We had no intention of helping anyone, anyways"
lol
i guess if i want to provide a Help Menu with an app, i can plan on writing it from scratch - lol
Title: Re: HtmlHelp function
Post by: jj2007 on July 08, 2009, 10:26:49 PM
I am contemplating to write one from scratch. HtmlHelp is an insult.

http://helpware.net/FAR/far_faq.htm#HH_CLOSE_ALL (http://helpware.net/FAR/far_faq.htm#HH_CLOSE_ALL)
QuoteWhen you call HH_CLOSE_ALL on shut down, the HH API creates another thread and sometimes does not return until after you have performed UnLoadLibrary(hhctrl.ocx). In this case the HH_CLOSE_ALL thread returns to nothing and causes an access violation.

Discussion:

Ralph Walden (x-Microsoft) describes the problem:

The switch to a background thread was done after I left (the MS help team)  in order to solve a problem with Visual Studio. I knew they should have fixed Visual Studio instead of "fixing" HTML Help (which wasn't broken). I've never actually tried it, but along with that change was a hack that allowed you to call the API in a way that it would create an interface, and then you'd call the API again to release that interface.
...
Here is an alternative to using HH_CLOSE_ALL. What I do with my applications is keep the handle of the HH Windows when making a help call: _HHwinHwnd := htmlhelp(...) and on shutdown call:
if IsWindow(_HHwinHwnd) then
   SendMessage( _HHwinHwnd, wm_close, 0, 0 );

This is 10 times faster code, and eliminates the need for HH_CLOSE_ALL completely.

... and unfortunately does not cover the cases when you 1. closed the help window manually and 2. opened more than one, e.g. for Masm32 lib and High Level help.

P.S.: HH_CLOSE_ALL does cause a GPF
Title: Re: HtmlHelp function
Post by: raymond on July 08, 2009, 11:31:14 PM
Thanks everyone.

It seems that I will have to upgrade the htmlhelp.inc file to include all the necessary equates and structs required to call the function. Although the descriptions of all the parameters seems to be in the SDK, I may also combine everything in a single function description (as we're used to with the Win32 manual).

I'll post all I have when completed and working (i.e. after doing a few tests of my own).
Title: Re: HtmlHelp function
Post by: jj2007 on July 09, 2009, 09:06:17 AM
I implemented HtmlHelp in RichMasm (http://www.masm32.com/board/index.php?topic=9044.msg73814#msg73814) using this code:

Quote.if eax==mtxt(".hlp")         ; eax=extension of help file, edi points to search string
   invoke WinHelp, hWnd, esi, HELP_PARTIALKEY, edi   ; complete code needed for *.hlp files
.else
   invoke HtmlHelp, hWnd, esi, HH_DISPLAY_INDEX, 0
   ; in data? section: handlesHH   dd 10 dup(?)   ; HtmlHelp window handles
   mov edx, offset handlesHH
   mov dword ptr [edx+4*10], 0   ; delimiter
   .Repeat
      mov ecx, [edx]
      add edx, 4
   .Until eax==ecx || ecx==0
   mov [edx-4], eax
   invoke FindWindowEx, eax, 0, chr$("HH Child"), 0
   .Repeat
      mov hHH, eax
      invoke GetWindow, hHH, GW_HWNDNEXT
   .Until eax==0      ; last window
   invoke FindWindowEx, hHH, 0, chr$("Edit"), 0
   .if eax
      sm eax, WM_SETTEXT, 0, edi   ; edit window found, set search text - hit Enter to activate
   .else
      invoke lstrcat, edi, chr$(".html")   ; if you are really lucky, it's a topic, and you spelled it correctly
      invoke HtmlHelp, hWnd, esi, HH_DISPLAY_TOPIC, edi
   .endif
.endif

In the WM_CLOSE handler, you need:

Quoteinvoke WinHelp, 0, 0, HELP_QUIT, 0   ; this line is the complete code needed for the *.hlp format
push esi
push ebx
mov esi, offset handlesHH
mov dword ptr [esi+4*10], 0      ; delimiter
.Repeat
   lodsd
   .Break .if eax==0
   mov ebx, eax
   .if rv(IsWindow, ebx)
      sm ebx, WM_CLOSE, 0, 0   ; see FAQ (http://helpware.net/FAR/far_faq.htm#HH_CLOSE_ALL)
   .endif
   pop eax
.Until 0
pop ebx
pop esi

Note the line "if you are really lucky, it's a topic, and you spelled it correctly". Many Masm32 *.chm files do not have a search tab, and this is the last resort. Most of the time, you will get "cannot visualise this page" - unless edi points to the exact name of a topic; and even then it depends on which name the author chose internally.
Example High Level help (\masm32\help\hlhelp.chm): Loop Code Methods works, Control Flow Techniques fails
Title: Re: HtmlHelp function
Post by: raymond on July 11, 2009, 02:37:39 AM
I updated the htmlhelp.inc file to include most of the necessary equates and structs.
I then added a call to the htmlhelp function and the program assembled properly. However, when I tried to run it, I got the following error message before any window ever appeared:

---------------------------
QERAledger9.exe - Unable To Locate Component
---------------------------
This application has failed to start because htmlhelp.dll was not found. Re-installing the application may fix this problem.
---------------------------

I then added a call to load the hhctrl.ocx module but still got the same message.

The program loaded and ran correctly only after commenting out ALL instructions pertaining to the htmlhelp functions. Leaving even only one of them in the middle of the code where it would not be used prevented the program from loading, probably because the htmlhelp.lib then had to be inked by the assembler.

As far as I know, there is no such thing as an htmlhelp.dll file. Any idea someone???

BTW, I'm running everything under WinXP.
Title: Re: HtmlHelp function
Post by: dedndave on July 11, 2009, 03:40:29 AM
here you go, Ray - this should help - lol - no pun intended

http://www.masm32.com/board/index.php?PHPSESSID=9f21a0a2b7af31a5bb173b6a9766bf20&topic=5082.0
Title: Re: HtmlHelp function
Post by: raymond on July 11, 2009, 05:08:02 AM
A zillion thanks Dave. :clap: :clap: :clap: The first test worked fine with that new lib.

I'll try it later with the htmlhelp.lib supplied with the SDK. That one is 35Kb vs 3Kb for the one which works fine. Wonder what the difference will be.
Title: Re: HtmlHelp function
Post by: ToutEnMasm on July 11, 2009, 05:35:56 AM

To raymond,
My ide use the htmlhelp since a few years with various results with differents lib.
(repeat of a previous post)
Quote
The html help libraries given by the masm32 package is too old and the one of the windows sdk  made errors at link time.
The only one who works is the one of the html help workshop.
The same html workshop can be found in the SDK help.
If you made a test with the lib of the windows sdk rc 7,can you post result here ?.




Title: Re: HtmlHelp function
Post by: jj2007 on July 11, 2009, 06:35:16 AM
I am using the version of 10.08.2004 (2746 bytes, attached) in RichMasm (http://www.masm32.com/board/index.php?topic=9044.msg73814#msg73814) (updated yesterday), and it works fine. Well, by the standards of M$, of course :wink

[attachment deleted by admin]
Title: Re: HtmlHelp function
Post by: raymond on July 25, 2009, 05:26:20 AM
UTTERLY TOTALY FRUSTRATING

I've finaly succeeded in calling a specific topic from a compiled help file whenever I need it. The program works like a charm under Win98. However, it crashes under a very peculiar circumstance with WinXP (SP3 Home Edition). I don't know yet how it would behave under Vista.

The program uses a half dozen different modal dialog boxes to get different kinds of input. Because the menu of the main window is not available to access the help file while the dialog box is open, I added a HELP button to each of those dialog boxes. And it is designed to open the help file at the topic related to that dialog box.

The frustrating part is that the program runs without crashing if I never call the help file. It also runs without crashing if I access all the dialog boxes and call the help file from each of them EXCEPT ONE. Whenever I open that particular dialog box and call the help file, the program will crash as soon as I call the help file from elsewhere or when I close the program (after closing the dialog box). The help file is called in exactly the same manner as with the other dialog boxes and from the main menu.

The exception code is always c0000005. The module where the exception occurs is generally "unknown" with the address either very low or very high. But I have seen ole32.dll indicated as the module on a few occasions, specially after calling the help file (and closing it) from numerous dialog boxes.

When I run the program with Ollydbg, it NEVER crashes when I call the help file from that dialog box and then call the help file from somewhere else or close the program immediately. However, I have succeeded in eventually crashing it with Ollydbg if I call the help file from that dialog box numerous times!!!!
Title: Re: HtmlHelp function
Post by: ToutEnMasm on July 25, 2009, 05:52:21 AM
To raymond,
Perhaps you could post your code or only the part with the help topic ?.
It will be more easy to help you.
Title: Re: HtmlHelp function
Post by: raymond on July 29, 2009, 08:20:24 PM
ENIGMA SOLVED

My program needed to access numerous relatively small data files which could vary in length with input. Whenever access to those files was needed by some part of the program, memory was allocated to read the file, usually in the 0x140000-0x160000 memory address space due to their small size. The memory handle was generally freed before returning from that task. In some cases, wanting to reuse the same variable to store another memory handle, the current value was released as a precaution against memory leak before reassigning another handle to that variable.

The hhctrl.ocx also requires some small chunks of memory whenever the Htmlhelp function is called. This was also being allocated in the same memory space, in areas which had been released by my program. By inadvertantly releasing it once more, it would have trashed some of the info required by the hhctrl.ocx to function properly, resulting in failures and crashes. This was not happening when using the HLP file probably because the WinHelp function did not require any memory allocation.

After reviewing my code in detail and modifying a few instructions to completely avoid duplicate release of any memory handles, the program now works like a charm.

As a side note, the htmlhelp.lib (1999 version) provided with the CHM HELP Workshop does not seem to rely on the hhctrl.ocx but will not assemble with the MASM32 package due to some missing exports. The htmlhelp.lib (Aug 2004 version) mentioned earlier in this thread works fine as long as a proper .inc file is provided. I've extracted some of the more important constants from the header file in the CHM HELP Workshop and included them in my htmlhelp.inc file which is attached. It may be a good idea if Hutch could include it in the next release of MASM32 (along with the htmlhelp.lib, Aug 2004 version, if considered redistributable).


[attachment deleted by admin]
Title: Re: HtmlHelp function
Post by: jj2007 on July 29, 2009, 09:28:17 PM
Congrats :bg
Title: Re: HtmlHelp function
Post by: ToutEnMasm on July 30, 2009, 05:55:30 AM

The htmlhelp.h is fully translated in the sdk rc7 here
http://www.masm32.com/board/index.php?topic=11531.msg86280#msg86280
The htmlhelp.sdk has more defines that the one posted,since further version of the sdk.
Title: Re: HtmlHelp function
Post by: raymond on August 22, 2009, 02:27:27 AM
ANOTHER HORROR STORY

I have another small program in the public domain to which I added another feature. While at it, I also wanted to provide it with a CHM help file instead of the HLP one, so that Vista users would be accomodated.

Everything works fine with one exception: IF I load a data file to process it without first calling the help file, that help file never gets displayed when I subsequently call it. Otherwise, if I call the help file before loading a data file, I can load any number of them (one at a time) and the help file gets displayed correctly any time I call it.

Although I don't like this patch, my current solution has been to call the help file, followed by an immediate HH_CLOSE_ALL command, just before I give control to the GetMessage loop for the main window. :green
Title: Re: HtmlHelp function
Post by: dedndave on August 22, 2009, 03:13:02 AM
there must be a solution to this
i have no vista to test on, though
i don't really like vista - lol