• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

让程序出现windows标准对话框式样的帮助_Delphi

Delphi 搞代码 3年前 (2018-08-09) 135次浏览 已收录 0个评论

unit Unit1;
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

const
  HH_DISPLAY_TOC   = $0001;
  HH_DISPLAY_TOPIC = $0000;

http://www.gaodaima.com/?p=66080让程序出现windows标准对话框式样的帮助_Delphi

  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
    { Private declarations }
  public
    { Public 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
  {
  调用缺省主题帮助
  此调用方式用于没有上下文ID号的情形,dwData可指定一个在CHM文件内的缺省htm文件,
  也可取Nil,这是HtmlHelp API最基本的一种用法。
  }
  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
  {
  调用关键字帮助
  此调用方式中dwData取索引文件(.hhk)中存在的关键字。
  }
  HtmlHelp(handle,pchar(‘help.chm’),HH_DISPLAY_INDEX,PDWORD(pchar(‘ambaSio’)));
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  dw: DWORD;
begin
  {
  调用上下文敏感帮助
  此调用方式用于含有映射信息的CHM文件, dwData取映射表中存在的ID号。
  }
  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 := 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
  {
  调用弹出式帮助
  PszFile通常取NULL,也可以指定一个CHM和一个在该CHM文件中的TEXT文件,DwData用
  于指定一个指向HH_POPUP结构的指针。
  }
  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));
  end;

end. 

欢迎大家阅读《让程序出现windows标准对话框式样的帮助_Delphi,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址