ITPub博客

首页 > 应用开发 > IT综合 > Delphi应用程序与Chm帮助关联的简单实现(源代码) (转)

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

原创 IT综合 作者:amyz 时间:2007-08-15 16:49:32 0 删除 编辑
Delphi应用程序与Chm帮助关联的简单实现(源代码) (转)[@more@]

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

请参考:Delphi程序与Chm帮助关联的简单实现
.NET/Develop/Article/18/18116.shtm">http://www.csdn.net/Develop/Article/18/18116.shtm 

2003-6-71925030.jpg" align=baseline border=0>

unit Unit1;
///  作者:李新  to:kelvinsdu@sina.com">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


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-958766/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3982
  • 访问量
    7896280