unit HTMLHELPCOMMON;
interface
uses Windows;
type
DWORD_PTR = ^DWORD;
Function HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT;
dwData
WORD_PTR ):HWND;
procedure CloseHtmlHelp;
implementation
uses SysUtils;
const
HHControlInstance:THandle=0;
dwCookie
WORD = 0;
var
HtmlHelpA:function ( hwndCaller:HWND;
pszFile
Char ;
uCommand:UINT;
dwData
WORD_PTR ):HWND;stdcall;
function HtmlHelp(hwndCaller:HWND;strFile:String;uCommand:UINT;
dwData
WORD_PTR ):HWND;
var
LFileName:String;
p
Char;
begin
if HHControlInstance=0 then
begin
LFileName := StringOfChar( ' ', 256);
p := PChar( LFilename );
GetSystemDirectory(p,255);
StrCat(p,'/hhctrl.ocx');
HHControlInstance := LoadLibrary( P );
if HHControlInstance = 0 then
raise exception.Create('Help system not installed!'#13' HTMLHELP cannot displayed!');
@HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');
if @HtmlHelpA = nil then
raise exception.Create('Function HTMLHELP cannot loaded!');
HtmlHelpA( 0, nil,$001C , (@dwCookie));
end;
result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );
end;
procedure CloseHtmlHelp;
begin
if HHControlInstance<>0 then
begin
HtmlHelpA( 0, nil, $001D, DWORD_PTR(dwCookie));
FreeLibrary(HHControlInstance);
end;
end;
end.
-------------------------------------------------------------------------------
function TMainForm.AppHtmlHelp(Command: Word;
Data: Longint;
var CallHelp: Boolean): Boolean;
var
ret:integer;
Hfile,AppPath:string;
begin
if not CallHelp then
exit;
AppPath := ExtractFilePath(Application.ExeName);
Hfile := Application.HelpFile;
case Command of
HELP_FINDER, HELP_CONTENTS:
ret := HtmlHelp(application.handle, pchar(Hfile), $0001, nil);
HELP_QUIT:
ret := HtmlHelp(application.handle, '', HELP_QUIT, nil);
//ret := HtmlHelp(application.handle, '', $0012, nil);
HELP_CONTEXT:
ret := HtmlHelp(application.handle, pchar(Hfile), $000f, DWORD_PTR(data));
//Data:HelpContext的值
end;
result:=ret<>0;
CallHelp := False;
end;
procedure TMainForm.FormCreate(Sender: TObject);
var
HtmlHelpFileName:string;
begin
HtmlHelpFileName:=ExtractFilePath(Application.ExeName)+'ngmfhelp.chm';
Application.HelpFile := HtmlHelpFileName;
Application.OnHelp := AppHtmlHelp;
//self.Brush.Bitmap:=image1.Picture.Bitmap;
end;
CHM应该会制作吧包括HelpContext