2010-09-08 20 views
1

有沒有人有任何提示可以讓我將Delphi幫助查看器與Delphi應用程序(2009年起)集成在一起。使用德爾福的Microsoft Help Viewer 1.X

感謝

+0

仍然使用創建的HTML幫助幫助和手冊與我的Delphi 2009應用程序。 :) – kludg 2010-09-08 16:03:31

回答

1

我假設你的意思的HTMLHelp,因爲WinHelp已被棄用,5年前停止了與Windows出貨。

這是我添加到我的ApplicationEvents對象的OnHelp事件處理程序的代碼:

function TdmGlobal.ApplicationEvents1Help(Command: Word; Data: Integer; 
    var CallHelp: Boolean): Boolean; 
var 
    HelpFile: string; 
    LocalFile: string; 
    HCommand : word; 
begin 
    CallHelp := False; 
    Result := False; 

    //i've named the help file the same as the executable, but with CHM extension 
    HelpFile := ChangeFileExt(Application.ExeName, '.chm'); 
    if not FileExists(HelpFile) then 
     Exit; 

    //Starting in 2003 HtmlHelp will no longer work from a network drive. 
    //Copy the file to the local machine's temp folder if it's sitting on a network share 
    if PathIsNetworkPath(HelpFile) then 
    begin 
     LocalFile := IncludeTrailingBackslash(GetTemporaryPath)+ExtractFilename(HelpFile); 
     if (not FileExists(LocalFile)) then 
     begin 
      try 
       CopyFile(PChar(HelpFile), PChar(LocalFile), False); 
      except 
       Exit; 
      end; 
     end 
     else 
     begin 
      if (GetUncompressedFileSize(HelpFile) <> GetUncompressedFileSize(LocalFile)) then 
      try 
       CopyFile(PChar(HelpFile), PChar(LocalFile), False); 
      except 
       //Exit; eat it 
      end; 
     end; 

     HelpFile := LocalFile; 
    end; 

    {translate WinHelp --> HTMLHelp} 
    case Command of 
    HELP_CONTENTS: 
     begin 
      HCommand := HH_DISPLAY_TOC; 
      Data := 0; 
     end; {HELP_CONTENTS..} 
    HELP_CONTEXT : HCommand := HH_HELP_CONTEXT; 
    HELP_CONTEXTPOPUP : HCommand := HH_HELP_CONTEXT; 
    HELP_FINDER : HCommand := HH_DISPLAY_TOPIC; 
    HELP_KEY : HCommand := HH_DISPLAY_INDEX; 
    HELP_QUIT : 
     begin 
      HCommand := HH_CLOSE_ALL; 
      Data := 0; 
     end; {HELP_QUIT..} 
    else 
     begin {default} 
      HCommand := HH_DISPLAY_TOPIC; 
      Data := 0; 
     end; {default..} 
    end; {case Command..} 

    hhCtrl.HtmlHelp(GetDesktopWindow(), HelpFile, HCommand, Data); 
end; 

包含了一些常量,以及功能hhCtrl.pas

function HtmlHelp(
     hwndCaller: HWND; 
     szFile: AnsiString; 
     uCommand: UINT; 
     dwData: DWORD): HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpA'; {external API call}