Simple implementation of Delphi program with CHM help

zhaozj2021-02-16  52

Simple implementation of Delphi program with CHM help

Author: Li kelvinsdu@sina.com QQ: 1348513

The help of the CHM format is a new format that appears after Windows98, with a .hlp format, more simple editing method, a richer picture. It is compiled by the CHM production tool, so you can theoretically make the help files as beautiful as the web page.

The simplest production method: first use the FronPage to make a help file, then compile with HTML Help Workshop to get the * .chm help file. HTML Help Workshop can go to Microsoft's website to download.

The help in the application can be divided into context associations and non-associated. The context is associated, refers to the help screen related to the current focus object (such as a form, text box, drop-down list box) after pressing the F1 key; the different objects, the help of the appearance. Non-related help, refers to the same help screen after pressing the F1 button anywhere. Below these two ways, talk about the simple implementation of Delphi.

First, non-related CHM help

In Delphi, you can call the CHM help file directly through the Shellexecute function, as follows:

Uses shellapi .......

Var hwndhelp: hwnd;

i: integer;

Begin

/ / Check if the help window already exists

HWndhelp: = FindWindow (nil, conhelptitle);

If hwndhelp <> 0 THEN // is closed if there is

SendMessage (HWndhelp, WM_Close, 0, 0);

I: = shellexecute (Handle, 'Open', Pchar (StrcurexePath '/ Help.chm'), NIL, NIL, SW_SHOWNORMAL);

IF i <> 42 THEN

ShowMessage ('Help.chm Help File Damage!');

END;

Second, the context associated with CHM help

To implement the context associated in Delphi, you can call the HTMLHELPA function in the HHCTRL HHCTRL.OCX control under the Windows System Directory in System32. Requirements the following steps:

1 Set the HelpContext property of the relevant control.

For example, the main form frmmain :: 10100, the text box EDTINPUT: 10101

Dialog DLGREPORT: 10200, combined list box CBREPORTEDIT: 10201

2 declaration htmlhelpa function

Function htmlhelpa (hwndcaller: longint; lphelpfile: String; wcommand: longint; dwdata: string): hwnd; stdcall; exTernal 'hhctrl.ocx'

3 F1 button response

// Public function showchmhelp displays different help screens.

Procedure showchmhelp (stopic: string);

VAR i: integer;

Begin

I: = HTMLHELPA (Application.Handle, Pchar (ExEPath '/ Help.chm'), HH_Display_topic, stopic;

IF i = 0 THEN

Begin

ShowMessage ('Help.chm Help File Damage!');

EXIT;

END;

END;

.

Function TFRMMAIN.FORMHELP (Command: Word; Data: Integer; var callhelp: boolean): boolean; begin

Case Data of

10100: Showchmhelp (frmmain.htm);

10101: Showchmhelp ('edtinput.htm');

...

Else Showchmhelp (Default.htm ');

END;

END;

Function TDLGREPORT.FORMHELP (Command: Word; Data: integer; var callhelp: boolean): boolean

Begin

Case Data of

10200: Showchmhelp ('DLGReport.htm');

10201: showchmhelp (cbreportedit.htm ');

...

Else Showchmhelp (Default.htm ');

END;

END;

In this way, the help can be achieved by the FormHelp event of different forms.

More introduced above

Delphi

Application

CHM

A simple implementation method of helping associated. If you want to achieve more complex associations (for example, a specific location in the help page

/

Relationship between bookmarks, please see

HTMLHELPA

Description of the function.

转载请注明原文地址:https://www.9cbs.com/read-23074.html

New Post(0)