News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HtmlHelp function

Started by raymond, July 08, 2009, 03:51:17 AM

Previous topic - Next topic

raymond

.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.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com


sinsi

Light travels faster than sound, that's why some people seem bright until you hear them.

ToutEnMasm

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.



jj2007

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

dedndave

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


jj2007

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", and you still haven't fixed it?? The HtmlHelp.lib downloaded today from our friends in Redmond 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
;               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
               endif
            .endif

dedndave

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

jj2007

I am contemplating to write one from scratch. HtmlHelp is an insult.

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

raymond

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).
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

jj2007

I implemented HtmlHelp in RichMasm 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
   .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

raymond

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.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com


raymond

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.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

ToutEnMasm


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