1

We are using the following code to call html help by A-links on the application for Delphi XE2:

var
  aLink: THH_AKLink;
begin
  ZeroMemory(@aLink, SizeOf(aLink));
  aLink.cbStruct := SizeOf(aLink);
{$WARNINGS OFF}
  aLink.pszKeywords := PChar(AnsiString(AKeyword));
{$WARNINGS ON}
  aLink.fIndexOnFail := False;
  HtmlHelpW(Handle, Application.HelpFile, HH_ALINK_LOOKUP, DWORD_PTR(@aLink))
end;

But if AKeyword is described on .chm file twice the application freezes (hangs). It seems something wrong on Delphi or system libraries. But how to fix this issue on the application?

Thanks a lot for the help!

Dmitry
  • 14,306
  • 23
  • 105
  • 189
  • can you show us the clipping from the. htm file where you have defined the ALink. – moskito-x Apr 26 '13 at 15:17
  • It's a CHM help file. – Dmitry Apr 26 '13 at 19:18
  • I Know . To compile you need a htm file as source. Show us that part where the ALink is. – moskito-x Apr 26 '13 at 19:53
  • ALinks are added by special application on special field. – Dmitry Apr 26 '13 at 21:11
  • Resurrecting this maybe: Its 2022 and we are having a similar issue. We are launching the chm from delphi 11 by helpcontext which works fine. But if the user clicks on the keywords secttion and selects a keyword with multiple links, the disambiguation popup does not appear and the host Delphi application is frozen. If we run the chm directly, we get the disambiguation popup with no problem. – Chris Were Jan 19 '22 at 23:17

2 Answers2

1

You're adding twice into a compiled chm file with a third party application 2 equal ALink .

Then you give Delphi XE2 the blame when the chm file is not working as expected?

1.) You can not use AKeyword with

HtmlHelpW(Handle, Application.HelpFile, HH_ALINK_LOOKUP, DWORD_PTR(@aLink))

you can try it with a KLink Keyword:

HtmlHelpW(Handle, Application.HelpFile+'>main', HH_DISPLAY_TOPIC, DWORD_PTR(nil));
HtmlHelpW(Handle, Application.HelpFile, HH_KEYWORD_LOOKUP, DWORD_PTR(@link));

ALink is a jump from his appearance here, as well as a KLink display or jump in Related Topics.

The list of topics found, however, is not based on keywords from the index, but on ALink names that were involved in the .htm file.

This can be used only with ALinks. The following is a ALink.

part of a xy.htm

<Object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
    <param name="ALink Name" value="UsingtheMenus">
</OBJECT>

2.) In your code I can not see following:

HtmlHelpW(Handle, Application.HelpFile, HH_DISPLAY_TOPIC, DWORD_PTR(nil));
  • You must first call the HH_DISPLAY_TOPIC command before calling HH_ALINK_LOOKUP , to ensure that the help window is created.

HH_ALINK_LOOKUP command

  • Help authors insert ALink names into target topic files using the HTML Help Compiler Information feature.
  • ALink : name="ALink Name" value="lookupAlink"
  • KLink : name="Keyword" value="lookupKeyword"

lookups are case sensitive. Multiple lookups are delimited by a semicolon.

Besides automatically generated keywords, when compiling a .htm source file .

enter image description here

Can you use an explicit KLink.

This is an explicit "KLink" the place may be anywhere in a .htm file, used for Keywords

<Object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
    <param name="Keyword" value="lookupKeyword">
</OBJECT>

The beneficial if you have a Error Message is created, the error is displayed and the Application continues normally. Source from answer How to add support of HTML help files (.chm)....

procedure TForm1.HHALINKLOOKUPClick(Sender: TObject);
var
link : HH_AKLINK;
szUrl,szKey,szMsgText,szMsgTitle,szWindow : AnsiString;
begin
   szKey      := Edit1.Text; // 'UsingtheMenus';
   szUrl      :='Overview.htm';
   szMsgText  :='Error: Can''t find "'+Edit1.Text+'"!';
   szMsgTitle :='Error: HH_ALINK_LOOKUP';
   szWindow   :='main';

   with link do begin
   cbStruct    := sizeof(HH_AKLINK) ;
   fReserved   := False;
   pszKeywords := PChar(szKey);
   pszUrl      := nil;
   pszMsgText  := PChar(szMsgText);
   pszMsgTitle := PChar(szMsgTitle);
   pszWindow   := PChar(szWindow);
   fIndexOnFail:= False;
   end;
   HtmlHelpW(Handle, Application.HelpFile+'>main', HH_DISPLAY_TOPIC, DWORD_PTR(nil));
   HtmlHelpW(Handle, Application.HelpFile, HH_ALINK_LOOKUP, DWORD_PTR(@link));
end;

And that do you get when you ALink "UsingtheMenus" calls without last letter "s".

enter image description here

Test your : with 3rd party application changed chm file

You can test any .chm file with HTML Help Workshop

enter image description here

enter image description here

enter image description here

enter image description here

Community
  • 1
  • 1
moskito-x
  • 11,832
  • 5
  • 47
  • 60
  • The problem isn't solved. The application hangs on help call. It works absolutelly the same with the line of code `HtmlHelpW(Handle, Application.HelpFile, HH_ALINK_LOOKUP, DWORD_PTR(@aLink))`. The line of code `HtmlHelpW(Handle, Application.HelpFile, HH_KEYWORD_LOOKUP, DWORD_PTR(@link));` doesn't work at all - it shows ALink on search field instead help article (search works BY NAME - not BY ALINK). – Dmitry May 02 '13 at 15:28
  • Do you really know what is A-Link? – Dmitry May 02 '13 at 15:34
  • ALink is only there to display `Topics`. No jump to ALink itself. Therefore, ALink is pretty useless. Also `KLinks` displays only the topics in which `KLinks` are included. Do you have the .chm file with HTML Workshop checked whether a reference is available to ALink or KLink ever in the .chm file. – moskito-x May 02 '13 at 18:58
0

The best answer at the current moment is to remove all duplicated A-link on CHM-file and ensure there is no duplicates on it.

Dmitry
  • 14,306
  • 23
  • 105
  • 189