-------------------------------------------------- ------------------------ How to make the program Windows standard dialog (such as dialog box when opening a file)? -------------------------------------------------- ------------------------ Unit unit1;
Interface
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: pchar; // window to display in End; //h_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 {private declarations} end;
Var Form1: TFORM1;
IMPLEMENTATION
{$ R * .dfm}
Function htmlhelp (hwndcaller: hwnd; pszfile: pchar; ucommand: uint; dwdata: pdword): hwnd; stdcall; external 'hhctrl.ocx' name 'htmlhelpa';
Procedure TForm1.Button1Click (Sender: TOBJECT); Begin {Call Default Theme Helps this calling method for the case where there is no context ID number, DWDATA can specify a default HTM file within the CHM file, or NIL, this is htmlhelp API's most basic use. Htmlhelp (Handle, Pchar ('Help.chm'), hh_display_topic, pdword (Pchar ('Article.htm')))); // or: htmlhelp (HAANDE, PCHAR ('HELP.CHM'), HH_Display_topic, NIL) ;
Procedure TForm1.Button2Click (Sender: TOBJECT); begin {call keyword helps this call mode in the dwdata retrieves the keywords in the index file (.hhk). } HTMLHELP (HANDLE, PCHAR ('Help.chm'), HH_Display_index, PDWORD (Pchar ('Ambasio'))); END;
Procedure TForm1.Button3Click (Sender: TOBJECT); VAR DW: DWORD; begin {Call context sensitive help this call mode for a CHM file containing mapping information, Dwdata projects the ID number existing in the tap. } DW: = 10; htmlhelp (Help.chm '), hh_help_context, pdword (@dw)); // I didn't try this way, maybe my CHM file does not contain mapping information reason. END;
procedure TForm1.Button4Click (Sender: TObject); var query: HH_FTS_Query; begin {invoke Help text search} with query do begin cbStruct: = sizeof (HH_FTS_Query); fUniCodeStrings: = false; iProximity: = 1; fStemmedSearch: = true; fExecute : = true; ftitleOnly: = false; pszwindow: = 'mainwin'; pszsearchquery: = nil; end; htmlhelp (handle, pchar ('help.chm'), hh_display_search, pdword (@query); end; procedure tform1. Button5Click (Sender: Tobject); var popup: hh_popup; begin {Call pop-up help PSZFile usually takes NULL, or you can specify a CHM and a Text file in the CHM file, DWDATA is used to specify a pointer to the HH_POPUP structure. } With popup do beg cbstruct: = sizeof (hh_popup); hinst: = 0; idstring: = 1; psztext: = nil; // pt: = pt; getCursorpos (Pt); CLRFOREGROUND: = colorRef (-1); CLRBACKGROUND : = ColorRef (-1); rcmargins.right: = 0; rcmargins.top: = 0; rcmargins.right: = 25; rcmargins.bittom: = 25; pszfont: = lpctstr ('bold'); end; htmlhelp Handle, Pchar ('Test.chm'), hh_display_text_popup, pdword (@Popup));
End.