If AKeyword is described on .chm file (html help) twice the application for Delphi XE2 freezes

StackOverflow https://stackoverflow.com/questions/15819792

  •  01-04-2022
  •  | 
  •  

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!

有帮助吗?

解决方案 2

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top