How can the topic be called in Delphi7 using A-Kewyword?

This section is for programmers. Please use it for all discussons on interfacing help with your applications and related subjects.

Moderators: Alexander Halser, Michael Schwarzl

Post Reply
User avatar
VictorL
Posts: 904
Joined: Mon Apr 13, 2009 11:03 am
Location: Moscow, Russia

How can the topic be called in Delphi7 using A-Kewyword?

Unread post by VictorL »

Hi! The programmist of us studied your document to call the topics from CHM but there's a question below.

How can the topic be called in Delphi7 using A-Kewyword? Application.HelpKeyword calls topic by K-Keywords.
As you adviced the context help descrides it next:


"Have you ever wondered how Delphi's online help works? When you select a property of a control in the object inspector or place the cursor on a keyword in the code editor, and press [F1], you get context sensitive help on that item.
This context sensitive help works with keywords. Delphi uses so-called "A-keywords" instead of normal "K-keywords" (that's another type of keywords in Winhelp which do not appear in the keyword index). But the principles are basically the same.
Let's assume that you want to display context sensitive help upon a keyword entered by the user or given by your application. First of all, you help file must define keywords with K-footnotes. The following example assumes that keywords are defined in your help file, otherwise you are unable to look up for keywords at all.
Imagine we have a Form1 with a Richedit1. The goal is now, when the user presses [F1] in the richedit, the application should extract the word beneath the cursor and search for help on it. If the keyword is found in the help file, the according help topic should be displayed. If there is no matching keyword, the keyword index should be displayed and the nearest match should be selected.
The [F1] key is trapped in the RichEdit1KeyDown event. This routine selects the current word and then calls a keyword search with DisplayHelpOnKeyword. Of course, you can use the DisplayHelpOnKeyword procedure alone as well.

procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key:

Word; Shift: TShiftState);

var

wStart, wLen: integer;

begin

if key = VK_F1 then

begin

wStart := richedit1.perform(EM_FINDWORDBREAK,

WB_MOVEWORDLEFT,

richedit1.selstart);

wLen := richedit1.perform(EM_FINDWORDBREAK,

WB_MOVEWORDRIGHT,

richedit1.selstart) - wStart;

Richedit1.selstart := wStart;

Richedit1.sellength := wLen;

DisplayHelpOnKeyword( trim(richedit1.seltext) );

key := 0; //don't process key

end;

end;

procedure TForm1.DisplayHelpOnKeyword(keyword: string);

var

Command: array[0..255] of Char;

begin

StrLcopy(Command, pchar(keyword), SizeOf(Command) - 1);

Application.helpcommand(HELP_KEY, Longint(@Command));

end;

This help file was made with Help & Manual. Download your own copy at http://www.helpandmanual.com!

But using this call it occures the message is shown at the end of this forum topic:
Maybe must additional modules be linked? If it needs then which that modules?
You do not have the required permissions to view the files attached to this post.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: How can the topic be called in Delphi7 using A-Kewyword?

Unread post by Alexander Halser »

The command parameter here must be a HH_ALINK structure, not a pchar.

You can find a proper implementation in our (outdated) EHS components avaialble from http://www.ec-software.com/downloads_delphi.html

This should get you started. You don't need to use EHS, just copy the code parts for the A-Link call.
Alexander Halser
Senior Software Architect, EC Software GmbH
Post Reply