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

类别:Delphi 点击:0 评论:0 推荐:

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

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

unit Unit1;
///  作者:李新  [email protected]  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

本文地址:http://com.8s8s.com/it/it5354.htm