我用的是D6+WIN2000,CHM制作软件是:HTML HELP WORKSHOP 和 QUICKCHM2.6;
我要的是能实现:按F1实现联机帮助效果,不是用WINSHELL来启动帮助文件。
请大家帮忙!
另外我从网上也找了个帮助的制作说明,但是却达不到效果,提示说:...不是WINDOWS帮助文件,或者已被破坏。
我要的是能实现:按F1实现联机帮助效果,不是用WINSHELL来启动帮助文件。
请大家帮忙!
另外我从网上也找了个帮助的制作说明,但是却达不到效果,提示说:...不是WINDOWS帮助文件,或者已被破坏。
解决方案 »
- 如何在只知道程序名,执行程序?
- ................一个关于打印的小问题。。。。。。。
- webbrowser很奇怪的问题!!!!!!!
- 在delphi5中如何实现windows 2000中的net send 功能
- 请教一个关于CreateProcessAsUser的问题。
- delphi 怎样实现 iobjectsafety 接口?
- 关于DBGrid,很Easy题~!
- 把一个xml文件装入ClientDataSet中,在Delphi6下可以,在Delphi5下怎么对TClientDataSet改动呢??
- 请问怎样使用WebBrowser控件?
- 一个关于移动的小问题。请教?
- 关于动态调用dll的问题。
- 具有可扩展的系统设计思想
Windows, SysUtils, Registry, dialogs, Forms,Messages;var
HHCtrlHandle: THandle = 0; //0 if hhctrl.ocx could not be loaded
//You can set this to false to override the default load API load on module initialization
AutoLoadAPI: Boolean = TRUE;const
hhctrlLib = 'hhctrl.ocx';{exports}
function GetPathToHHCtrlOCX: string;
procedure LoadHtmlHelp;
procedure UnloadHtmlHelp;
function HelpTopic(sDispayTopic: string):boolean; //调用主题页面
{ Externals from HHCTRL.OCX }
var //functions are invalid if HHCtrlHandle = 0
HtmlHelpA: function(hwndCaller: HWND; pszFile: PAnsiChar;
uCommand: UInt; dwData: DWORD): HWND; stdcall;
HtmlHelpW: function(hwndCaller: HWND; pszFile: PWideChar;
uCommand: UInt; dwData: DWORD): HWND; stdcall;
HtmlHelp: function(hwndCaller: HWND; pszFile: PChar;
uCommand: UInt; dwData: DWORD): HWND; stdcall;
{ Commands to pass to HtmlHelp() }
const
HH_INITIALIZE = $001C; // Initializes the help system.
HH_UNINITIALIZE = $001D; // Uninitializes the help system.
HH_DISPLAY_TOC = $0001; // not currently implemented
HH_DISPLAY_TOPIC = $0000;
HH_HELP_CONTEXT = $000F; // display mapped numeric value in dwData
HH_CLOSE_ALL = $0012; // close all windows opened directly or indirectly by the callerimplementationfunction GetWinSysDir: String;
var path: array[0..260] of Char;
begin
GetSystemDirectory(path, SizeOf(path));
result := path;
if result[length(result)] = '\' then
SetLength(result, length(result)-1);
end;function GetPathToHHCtrlOCX: string;
const hhPathRegKey = 'CLSID\{adb880a6-d8ff-11cf-9377-00aa003b7a11}\InprocServer32';
{$IFDEF D4PLUS} // -- Delphi >=4 ------------
var Reg: TRegistry;
{$ENDIF}
begin
{$IFDEF D4PLUS} // -- Delphi >=4 ------------
result := ''; //default return
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CLASSES_ROOT;
if Reg.OpenKeyReadOnly(hhPathRegKey) then //safer call under NT
begin
result := Reg.ReadString(''); //default value
Reg.CloseKey;
if (result <> '') and (not FileExists(result)) then //final check - file must exist
result := '';
end;
Reg.Free;
{$ELSE} // -- Delphi <4 ------------
Result := GetWinSysDir + '\hhctrl.ocx';
{$ENDIF}
end;//**********setup HTML Help API function interface *******************
procedure LoadHtmlHelp;
var OcxPath: string;
begin
if HHCtrlHandle = 0 then
begin
OcxPath := GetPathToHHCtrlOCX;
if (OcxPath <> '') and FileExists(OcxPath) then
begin
HHCtrlHandle := LoadLibrary(PChar(OcxPath));
if HHCtrlHandle <> 0 then
begin
@HtmlHelpA := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
@HtmlHelpW := GetProcAddress(HHCtrlHandle, 'HtmlHelpW');
@HtmlHelp := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
end;
end;
end;
end;procedure UnloadHtmlHelp;
begin
if HHCtrlHandle <> 0 then
begin
FreeLibrary(HHCtrlHandle);
@HtmlHelpA := nil;
@HtmlHelpW := nil;
@HtmlHelp := nil;
HHCtrlHandle := 0;
end;
end;//******************* 调用主题页面 *********************************************
function HelpTopic(sDispayTopic: string):boolean;
var
irtn: integer;
stmp: string;
begin
stmp := sDispayTopic;
irtn := htmlhelp(GetDesktopWindow, PChar(stmp), HH_DISPLAY_TOPIC, 0);
if irtn > 0 then
SetForegroundWindow(irtn);
if irtn <= 0 then
begin
Result := False;
Application.MessageBox('帮助文件不存在!', '操作提示', MB_IconInformation + MB_SystemModal);
exit;
end;
Result := True;
end;initialization
if AutoLoadAPI then
LoadHtmlHelp;
finalization
UnloadHtmlHelp;
end.
Shift: TShiftState);
begin
if key = 112 then HelpTopic('Help.chm::/' + '5.2.2.htm');
end;例中的'5.2.2.htm'为对应的htm文件
然后再要调用的窗口中添加如下代码(其中myhelp.chm是做好的帮助文件)
type
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
//////////////////////////////
implementationuses ShellAPI
///////////////////////////////
procedure Tf_tiaojie.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_F1
then
ShellExecute(0,'open',pchar(ExtractFilePath(Application.Exename)+'myhelp.chm'),nil,nil,SW_SHOWNORMAL);end;
这样就ok了