發信人: leenb (nb), 信區: borlanddev
標 題: re: delphi中如何呼叫chm幫助檔案
發信站: 哈工大紫丁香 (2023年04月19日19:58:44 星期六), 站內信件
如果只是簡單的呼叫,可以用:
uses shellapi
...
begin
shellexecute(handle,nil,'indexsyy.chm',nil,nil,sw_shownormal);
end;
如果要實現較複雜的功能:
unit unit1;
inte***ce
uses
windows, messages, sysutils, classes, graphics, controls, forms, dialogs,
stdctrls;
const
hh_display_toc = $0001;
hh_display_topic = $0000;
hh_close_all = $0012;
hh_display_index = $0002;
hh_help_context = $000f;
hh_display_search= $0003;
hh_display_text_popup = $000e;
type
hh_fts_query = record
cbstruct : integer; // sizeof structure
funicodestrings : bool; // true if all strings are unicode
pszsearchquery : pchar; // string with the search query
iproximity : longint; // word proximity
fstemmedsearch : bool; // true for stemmed search only
ftitleonly : bool; // true for title search only
fexecute : bool; // true to initiate the search
pszwindow : pchar; // window to display in
end; // hh_fts_query
hh_popup = record
cbstruct: integer; // sizeof this structure
hinst: longint; // instance handle for string resource
idstring: uint; // string resource id, or text id if pszfile is specified in
htmlhelp call
psztext: lpctstr; // used if idstring is zero
pt: tpoint; // top center of popup window
clrforeground: colorref; // use -1 for default
clrbackground: colorref; // use -1 for default
rcmargins: trect; // amount of space between edges of window and text, -1 for
each member to ignore
pszfont: lpctstr; // facename, point size, char set, bold italic underline
end;
type
tform1 = class(tform)
button1: tbutton;
button2: tbutton;
button3: tbutton;
button4: tbutton;
button5: tbutton;
procedure button1click(sender: tobject);
procedure button2click(sender: tobject);
procedure button3click(sender: tobject);
procedure button4click(sender: tobject);
procedure button5click(sender: tobject);
private
public
end;
var
form1: tform1;
implementation
function htmlhelp(hwndcaller: hwnd; pszfile: pchar; ucommand: uint;
dwdata: pdword): hwnd; stdcall; external 'hhctrl.ocx' name 'htmlhelpa';
procedure tform1.button1click(sender: tobject);
begin
htmlhelp(handle,pchar('help.chm'),hh_display_topic,pdword(pchar('article.htm'))
);
//或:htmlhelp(handle,pchar('help.chm'),hh_display_topic,nil);
end;
procedure tform1.button2click(sender: tobject);
begin
htmlhelp(handle,pchar('help.chm'),hh_display_index,pdword(pchar('ambasio')));
end;
procedure tform1.button3click(sender: tobject);
var
dw: dword;
begin
dw := 10;
htmlhelp(handle,pchar('>help.chm'),hh_help_context,pdword(@dw));
//這種方式我沒試出來,可能是我的chm檔案不含對映資訊的緣故。
end;
procedure tform1.button4click(sender: tobject);
var
query: hh_fts_query;
begin
with query do
begin
cbstruct := sizeof(hh_fts_query);
funicodestrings := false;
iproximity := 10;
fstemmedsearch := true;
fexecute := true;
ftitleonly := false;
pszwindow := 'mainwin';
pszsearchquery := 'd';
end;
htmlhelp(handle,pchar('help.chm'),hh_display_search,pdword(@query));
end;
procedure tform1.button5click(sender: tobject);
var
popup: hh_popup;
begin
with popup do
begin
cbstruct := sizeof(hh_popup);
hinst:= 0;
idstring:=1;
psztext:=nil;
//pt:= pt;
getcursorpos(pt);
clrforeground:=colorref(-1);
clrbackground:=colorref(-1);
rcmargins.left := 0;
rcmargins.top := 0;
rcmargins.right := 25;
rcmargins.bottom := 25;
pszfont:=lpctstr('bold');
end;
htmlhelp(handle,pchar('test.chm'),hh_display_text_popup,pdword(@popup));
//這個我也沒搞太明白,能出現popup,但無幫助內容。
end;
end.
在Delphi中呼叫CHM幫助檔案
在delphi中,要呼叫chm檔案可以通過引用hhctrl.ocx檔案的函式htmlhelpa實現。不過在這裡,我們也可以使用api函式shellexecute來開啟chm幫助檔案。在網上找到的資料,通常以 shellexecute self.handle,open help.chm sw show...
Delphi2007的新功能之呼叫chm型別幫助
在delphi2007中的windows單元增加了許多api函式,其中就包括 function htmlhelp hwndcaller hwnd pszfile pchar ucommand uint dwdata dword hwnd function htmlhelpa hwndcaller h...
Qt 呼叫 chm格式的檔案
在windows平台下,有乙個系統預設的,開啟chm格式檔案的exe.hh.exe 在qt中使用,只需要 qprocess process process.startdetached hh.exe help.chm process.waitforstarted 這樣,就可以開啟幫助檔案。定位操作 幫...