chm格式的文件怎么在delphi中使用调出?(100分)

  • 主题发起人 主题发起人 justsoso51
  • 开始时间 开始时间
J

justsoso51

Unregistered / Unconfirmed
GUEST, unregistred user!
chm格式的文件怎么在delphi中使用调出?点击 帮助 或f1调出chm的帮助文件?具体点的代码给一些好吗谢谢
 
{
This unit has been written by Jan Goyvaerts <http://www.jgsoft.com>
It has been placed into the publicdo
main.
Add this unit to the uses clause of any unit in your application,
and any help requests will automatically be translated into the
proper HTML Help calls.
You will need to specify the .chm file that contains your HTML Help
in the help file setting in Delphi's project options.
Otherwise, nothing will happen when the user presses F1.
The unitdo
es its work by assigning its own event handler to the
Application.OnHelp event. This means you must take care not to
assign your own handler to Application.OnHelp, as this will
defeat the purpose of this unit.
Also, this simple unit will ignore any form's HelpFile property.
This property is new in Delphi 4
}
unit UseHTMLHelp;
interface
uses
Windows, Messages, SysUtils, Forms;
// Commands to pass to HtmlHelp()
const
HH_DISPLAY_TOPIC = $0000;
HH_HELP_FINDER = $0000;
// WinHelp equivalent
HH_DISPLAY_TOC = $0001;
HH_DISPLAY_INDEX = $0002;
HH_DISPLAY_SEARCH = $0003;
HH_SET_WIN_TYPE = $0004;
HH_GET_WIN_TYPE = $0005;
HH_GET_WIN_HANDLE = $0006;
HH_ENUM_INFO_TYPE = $0007;
// Get Info type name, call repeatedly to enumerate, -1 at end
HH_SET_INFO_TYPE = $0008;
// Add Info type to filter.
HH_SYNC = $0009;
HH_RESERVED1 = $000A;
HH_RESERVED2 = $000B;
HH_RESERVED3 = $000C;
HH_KEYWORD_LOOKUP = $000D;
HH_DISPLAY_TEXT_POPUP = $000E;
// display string resource id or text in a popup window
HH_HELP_CONTEXT = $000F;
// display mapped numeric value in dwData
HH_TP_HELP_CONTEXTMENU = $0010;
// text popup help, same as WinHelp HELP_CONTEXTMENU
HH_TP_HELP_WM_HELP = $0011;
// text popup help, same as WinHelp HELP_WM_HELP
HH_CLOSE_ALL = $0012;
// close all windows opened directly or indirectly by the caller
HH_ALINK_LOOKUP = $0013;
// ALink version of HH_KEYWORD_LOOKUP
HH_GET_LAST_ERROR = $0014;
// not currently implemented // See HHERROR.h
HH_ENUM_CATEGORY = $0015;
// Get category name, call repeatedly to enumerate, -1 at end
HH_ENUM_CATEGORY_IT = $0016;
// Get category info type members, call repeatedly to enumerate, -1 at end
HH_RESET_IT_FILTER = $0017;
// Clear the info type filter of all info types.
HH_SET_INCLUSIVE_FILTER = $0018;
// set inclusive filtering method for untyped topics to be included in display
HH_SET_EXCLUSIVE_FILTER = $0019;
// set exclusive filtering method for untyped topics to be excluded from display
HH_INITIALIZE = $001C;
// Initializes the help system.
HH_UNINITIALIZE = $001D;
// Uninitializes the help system.
HH_PRETRANSLATEMESSAGE = $00FD;
// Pumps messages. (NULL, NULL, MSG*).
HH_SET_GLOBAL_PROPERTY = $00FC;
// Set a global property. (NULL, NULL, HH_GPROP)
function HtmlHelp(hwndCaller: THandle;
pszFile: PChar;
uCommand: cardinal;
dwData: longint): THandle;
stdcall;
implementation
function HtmlHelp(hwndCaller: THandle;
pszFile: PChar;
uCommand: cardinal;
dwData: longint): THandle;
stdcall;
external 'hhctrl.ocx' name 'HtmlHelpA';
type
TUseHTMLHelp = class(TObject)
function ApplicationHelp(Command: Word;
Data: Longint;
var CallHelp: Boolean): Boolean;
end;

function TUseHTMLHelp.ApplicationHelp(Command: Word;
Data: Longint;
var CallHelp: Boolean): Boolean;
begin
// Make sure VCLdo
esn't activate WinHelp
CallHelp := False;
Result := True;
if Command in [HELP_CONTEXT, HELP_CONTEXTPOPUP] then
// Ordinary context jump
HtmlHelp(Application.MainForm.Handle, PChar(Application.HelpFile), HH_HELP_CONTEXT, Data)
else
if Command = HELP_KEY then
// Keyword lookup
HtmlHelp(Application.MainForm.Handle, PChar(Application.HelpFile), HH_DISPLAY_INDEX, Data)
else
if Command = HELP_QUIT then
// Application quits -> close all its help files
HtmlHelp(Application.MainForm.Handle, nil, HH_CLOSE_ALL, 0)
else
// Any other command -> display table of contents
HtmlHelp(Application.MainForm.Handle, PChar(Application.HelpFile), HH_HELP_FINDER, 0)
end;

var
HTMLHelpUser: TUseHTMLHelp;
initialization
HTMLHelpUser := TUseHTMLHelp.Create;
Application.OnHelp := HTMLHelpUser.ApplicationHelp;
finalization
Application.OnHelp := nil;
HTMLHelpUser.Free;
end.

要简单,可以在需要的单元相应部分加入一下声明即可:
interface
function HtmlHelp(hwndCaller: THandle;
pszFile: PChar;
uCommand: cardinal;
dwData: longint): THandle;
stdcall;
implementation
function HtmlHelp(hwndCaller: THandle;
pszFile: PChar;
uCommand: cardinal;
dwData: longint): THandle;
stdcall;
external 'hhctrl.ocx' name 'HtmlHelpA';
 
shellExecute
 
use shellAPI
//
ShellExecute(Handle,'open',pchar(ExtractFilePath(paramstr(0))+'my.chm'),nil,nil,SW_SHOWNORMAL)
 
根据需要,选择前面的两种方法都可以
 
帮助文件也可这样调出
MessageDlgPosHelp('一个示例', mtInformation, [mbOK, mbHelp], 0, 200, 20, '文件名');
 
再问一句,delpi的随盘安装程序哪里可以下载阿》我指的是install shield版的。我的d版是单张的没有阿。
 
www.playicq.com
 
去 http://www.ttdown.com 下载一个 WiseInstall Professional V9.02 更好用些.
 
ShellExecute(0,'open',pchar(ExtractFilePath(Application.exename)+'help.chm'),nil,nil,SW_SHOWNORMAL)
 
接受答案了.
 
后退
顶部