我用HTML HELP WORKSHOP 做完帮助后(名字叫  help.chm)怎么样才能在窗体上按下F1后就弹出我的帮助文件呀!

解决方案 »

  1.   

    先把form1的keypreview设置为true,然后:
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key= vk_f1 then
      showmessage('');
    end;
      

  2.   

    Delphi并不支持HTML HELP帮助系统,它仍然使用WinHelp。不过调用Windows系统目录System32下的HHCTRL.OCX,利用其中的HtmlHelpA函数接口可以自行实现HTML HELP帮助。
     
    公共模块代码如下: unit HTMLHELPCOMMON
       interface
     uses Windows;
       type DWORD_PTR = ^DWORD;
       Function
      HtmlHelp(hwndCaller:HWND;strFile:String;
     uCommand:UINT; dwData:DWORD_PTR ):HWND;
       procedure CloseHtmlHelp;
       implementation
     uses
     SysUtils;
     const
     HHControlInstance:THandle=0;
     dwCookie :DWORD = 0;
     var
     HtmlHelpA:function ( hwndCaller:HWND; pszFile:PChar ; uCommand:UINT; dwData:DWORD_PTR ):HWND;stdcall;
       function HtmlHelp(hwndCaller:HWND;strFile:String; uCommand:UINT; dwData:DWORD_PTR ):HWND;
     var
     LFileName:String;
     p:PChar;
     begin
     if HHControlInstance=0 then
     begin
     LFileName := StringOfChar( ' ', 256);
     p := PChar( LFilename );
     GetSystemDirectory(p,255);
     StrCat(p,'\HHCTRL.OCX');
     HHControlInstance := LoadLibrary( P );
     if HHControlInstance = 0 then
     raise exception.Create('Help system not installed!'#13' HTMLHELP cannot displayed!');
     @HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');
     if @HtmlHelpA = nil then
     raise exception.Create('Function HTMLHELP cannot loaded!');
     HtmlHelpA( 0, nil,$001C , (@dwCookie));
     end;
     result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );
     end;
       procedure CloseHtmlHelp;
     begin
     if HHControlInstance<>0 then
     begin
     HtmlHelpA( 0, nil, $001D, DWORD_PTR(dwCookie));
     FreeLibrary(HHControlInstance);
     end;
     end;
       end. 
     
    两个函数分别初始化和释放调用接口。其它模块只须按约定调用即可。例如:
     
    HtmlHelp( handle, htmlhelpfilename+'::/welcome.htm',$0000, nil);
     
    显示htmlhelpfilename对应的帮助文件的welcome页面。
     
    上下文敏感帮助需要借用Delphi对WinHelp的支持。当用户按 F1 键时,程序将自动触发OnHelp事件,截获它,编写自己的处理代码即可。 ... ...
     Application.HelpFile := htmlhelpfilename;
     tmpOnHelp := Application.OnHelp;
     Application.OnHelp := AppHtmlHelp;
     ... ...
       function TForm1.AppHtmlHelp(Command: Word; Data: Longint;
      var CallHelp: Boolean): Boolean;
      var ret:integer;Hfile:string;
     begin
     if not CallHelp then exit;
     AppPath := ExtractFilePath(Application.ExeName);
     Hfile := AppPath + Application.HelpFile;
     case Command of
     HELP_FINDER, HELP_CONTENTS:
      ret := HtmlHelp(handle, pchar(Hfile), $0001, nil);
     HELP_QUIT:
      ret := HtmlHelp(0, '', $0012, nil);
     HELP_CONTEXT:
      ret := HtmlHelp(handle, pchar(Hfile), $000f, DWORD_PTR(data));
     end;
     result:=ret<>0;
       CallHelp := False;
     end; 
    这样,我们就有另一种方法调用帮助文件,与传统WinHelp调用方法一样:  application.helpcommand(HELP_FINDER, 0);
     application.helpcommand(HELP_quit, 0); 
    ... ...
     
      

  3.   

    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=$70 then
        form2.show;
    end;
      

  4.   

    keypreview设置为true
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=112 then
        ShellExecute(Handle, 'open', Pchar('c:\help.chm'), nil, nil, SW_SHOWNORMAL);end;
      

  5.   

    If Msg.message = Wm_KeyDown Then
            Begin
                Case Msg.wParam Of
                    VK_F1:
                        Begin
                            PubFun_unit.CallHelp(0);
                        End;
                End;
            End;
      

  6.   

    我认为这样比较稳定
    1.加一个Actionlist(standard页)
    2.双击Actionlist
    3.单击 new action
    4.双击 刚加的action
    procedure TTransComWaveoutForm.HelpExecute(Sender: TObject);
    begin
    winexec(filename,sw_shownormal);
    end;
    5.将shortcut 设置成F1