Delphi application is simple implementation with CHM helps (source code)
Please refer to: Delphi program and CHM help association simple implementation http://www.9cbs.net/develop/Article/18/18116.shtm
unit Unit1; /// Author: Li kelvinsdu@sina.com QQ: 1348513interface
Uses Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs, Comctrls, Stdctrls; Const Conhelptitle = 'Research Project Management System 2.0'; hh_display_topic = 0; // Precalated MSDN, there are many command, change itself into 0 , type TForm1 1 like = class (TForm) EdtProjectManager: TEdit; // helpcontext = 10101 Button1: TButton; Label1: TLabel; EdtFinanceInput: TEdit; // helpcontext = 10102 function FormHelp (Command: Word; Data: Integer; var CallHelp: Boolean): Boolean; procedure Button1Click (Sender: TObject); private {Private declarations} public {public declarations} end; procedure ShowChmHelp (sTopic: string); var Form1: TForm1; function HtmlHelpA (hwndcaller: Longint; lpHelpFile: string Wcommand: longint; dwdata: string): hWnd; stdcall; exTernal 'hhctrl.ocx'
ImplementationUses unit2; {$ r * .dfm} function currentexefilepath: String; // Returns the current path VAR CDIR: String; Begin Result: = '; setlength (cdir, 144); if getcurrentdirectory (144, Pchar (CDIR)) <> 0 Then SetLength (CDir, StrLen (PChar (CDir))) Else RaiseLastWin32Error; Result: = CDir; End; procedure ShowChmHelp (sTopic: string); var i: integer; begin i: = HtmlHelpA (Application.Handle, Pchar (CurrentexefilePath '/ help.chm'), hh_display_topic, stopic); if i = 0 THEN BEGIN SHOWMESSAGE ('Help.chm Help file corrupted!'); End;
function TForm1.FormHelp (Command: Word; Data: Integer; var CallHelp: Boolean): Boolean; begin case Data of 10100: ShowChmHelp ( 'SystermIntroduction.htm'); 10101: ShowChmHelp ( 'ProjectManager.htm'); 10102: ShowChmHelp ('FinanceInput.htm'); Else Showchmhelp ('systermintroduction.htm'); End;
Procedure TForm1.Button1Click (Sender: TOBJECT); Begin Okbottomdlg: = tokbottomdlg.create (nil); trybottomdlg.showmodal; finally okbottomdlg.free; end; end;
End.
/
Unit unit2;
Interface
Uses Windows, Sysutils, Classes, Graphics, Forms, Controls, Stdctrls, Buttons, ExtCtrls
type TOKBottomDlg = class (TForm) OKBtn: TButton; CancelBtn: TButton; cbQuickQuery: TComboBox; // helpcontext = 10200 EdtSuperQuery: TEdit; // helpcontext = 10201 function FormHelp (Command: Word; Data: Integer; var CallHelp: Boolean): Boolean; private {private declarations}
VAR OKBOTTOMDLG: TOKBOTTOMDLG;
ImplementationUses Unit1; {$ r * .dfm}
function TOKBottomDlg.FormHelp (Command: Word; Data: Integer; var CallHelp: Boolean): Boolean; begin case Data of 10200: ShowChmHelp ( 'QuickQuery.htm'); 10201: ShowChmHelp ( 'SuperQuery.htm'); else ShowChmHelp ( 'Systermintroduction.htm'); End; end;
EN