Delphi应用程序与Chm帮助关联的简单实现(源代码)

王朝delphi·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

Delphi应用程序与Chm帮助关联的简单实现(源代码)

请参考:Delphi程序与Chm帮助关联的简单实现

http://www.csdn.net/Develop/Article/18/18116.shtm

unit Unit1;

/// 作者:李新 kelvinsdu@sina.com QQ:1348513

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

ComCtrls, StdCtrls;

const

conHelpTitle='科研项目管理系统 2.0';

HH_DISPLAY_TOPIC=0;//先查msdn,有好多command,自己改成0,1之类的

type

TForm1 = 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'

implementation

uses Unit2;

{$R *.DFM}

Function CurrentExeFilepath:String; //返回当前的路径

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 帮助文件损坏!');

exit;

end;

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;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

OKBottomDlg:=TOKBottomDlg.create(nil);

try

OKBottomDlg.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 }

public

{ Public declarations }

end;

var

OKBottomDlg: TOKBottomDlg;

implementation

uses 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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航