delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
492 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (4)


How to easily use HTML Help files in your programsGo to Dave Murray's websiteComponent available for this articleFormat this article printer-friendly!Bookmark function is only available for registered users!
Convert all WinHelp calls to HTML Help
Product:
Delphi 3.x (or higher)
Category:
System
Skill Level:
Scoring:
Last Update:
12/23/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet Windows-Help WinHelp HTML-Help Help chm HTMLHelpA
Times Scored:
8
Visits:
7677
Uploader: Dave Murray
Company: Conspiracy Software
Reference: Irongut's Delphi Pages
Component Download: http://www.paranoia.clara.net/downloads/using_html_help.zip
 
Question/Problem/Abstract:
Do you long to move from WinHelp to HTML Help in your programs? The unit below converts all WinHelp calls to HTML Help enabling you to upgrade with the minimum of effort.
Answer:



An updated version of this article can be found on Irongut's Delphi Pages.


Save this unit to a directory on your Environment Options|Library|Library Path and add to your project uses clause, all WinHelp requests will now be translated to HTML Help. Specify your *.chm file in the Project Options|Application|Help file setting. Context sensitive help will work as normal, use TApplication.HelpCommand to send help commands. eg. Application.HelpCommand(HELP_KEY, DWORD(keyData))



unit dmHTMLHelp;
{Unit to translate WinHelp requests into HTML Help and call the API.}
{Written by Dave Murray, October 2001. dmurray@worldmark.com}
{NOTES:
This unit assigns its own handler to the Application.OnHelp event.
DO NOT assign your own handler to Application.OnHelp.
Also, this unit ignores any form's HelpFile property. (Delphi 4+)}

interface

uses
  Windows, Messages, SysUtils, Forms;

const
  {commands to pass to HtmlHelp(), see HTML Help API Reference}
  HH_DISPLAY_TOPIC        = $0000; {open help topic}
  HH_HELP_FINDER          = $0000; {backwards compatibility,use HH_DISPLAY_TOPIC instead}
  HH_DISPLAY_TOC          = $0001; {select Contents tab in nav pane}
  HH_DISPLAY_INDEX        = $0002; {select Index tab + search for keyword}
  HH_DISPLAY_SEARCH       = $0003; {select Search tab in nav pane}
  HH_SET_WIN_TYPE         = $0004;
  HH_GET_WIN_TYPE         = $0005;
  HH_GET_WIN_HANDLE       = $0006;
  HH_ENUM_INFO_TYPE       = $0007;
  HH_SET_INFO_TYPE        = $0008;
  HH_SYNC                 = $0009;
  HH_RESERVED1            = $000A; {not currently implemented}
  HH_RESERVED2            = $000B; {not currently implemented}
  HH_RESERVED3            = $000C; {not currently implemented}
  HH_KEYWORD_LOOKUP       = $000D;
  HH_DISPLAY_TEXT_POPUP   = $000E; {display string resource/text in a popup}
  HH_HELP_CONTEXT         = $000F; {display topic for context number}
  HH_TP_HELP_CONTEXTMENU  = $0010; {text popup help, same as HELP_CONTEXTMENU}
  HH_TP_HELP_WM_HELP      = $0011; {text popup help, same as HELP_WM_HELP}
  HH_CLOSE_ALL            = $0012; {close all windows opened by caller}
  HH_ALINK_LOOKUP         = $0013; {ALink version of HH_KEYWORD_LOOKUP}
  HH_GET_LAST_ERROR       = $0014; {not currently implemented}
  HH_ENUM_CATEGORY        = $0015;
  HH_ENUM_CATEGORY_IT     = $0016;
  HH_RESET_IT_FILTER      = $0017;
  HH_SET_INCLUSIVE_FILTER = $0018;
  HH_SET_EXCLUSIVE_FILTER = $0019;
  HH_INITIALIZE           = $001C;
  HH_UNINITIALIZE         = $001D;
  HH_PRETRANSLATEMESSAGE  = $00FD;
  HH_SET_GLOBAL_PROPERTY  = $00FC;

function HtmlHelp(hwndCaller: THandle; pszFile: PChar; uCommand: cardinal; dwData: longint): THandle; stdcall;

implementation

function HtmlHelp(hwndCaller: THandle; pszFile: PChar; uCommand: cardinal; dwData: longint): THandle; stdcall; external 'hhctrl.ocx' name 'HtmlHelpA'; {external API call}

type
  TdmHTMLHelp = class(TObject) {encapsulates function}
    function ApplicationHelp(Command: Word; Data: Longint; var CallHelp: Boolean): Boolean;
  end; {TdmHTMLHelp..}

function TdmHTMLHelp.ApplicationHelp(Command: Word; Data: Longint; var CallHelp: Boolean): Boolean;
{translates WinHelp commands to HTMLHelp commands + calls API}
var
  HCommand : word;
begin
  {make sure VCL doesn't activate WinHelp + function succeeds}
  CallHelp := false;
  result := true;
  {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..}
  {call HTML Help API}
  HtmlHelp(Application.MainForm.Handle, PChar(Application.HelpFile), HCommand, Data);
end; {function TdmHTMLHelp.ApplicationHelp}

var
  HTMLHelper: TdmHTMLHelp;

initialization
  {create object + assign event handler}
  HTMLHelper := TdmHTMLHelp.Create;
  Application.OnHelp := HTMLHelper.ApplicationHelp;
finalization
  {free event handler + object}
  Application.OnHelp := nil;
  HTMLHelper.Free;
end.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Doesn't work in Delphi 6
    S Dingenouts (Jun 1 2002 5:47PM)

This code doesn't work in Delphi 6. Here's why:

The helpsystem in Delphi 6 has changed a lot, to support Kylix. The context-help and jump-help do no longer call Application.HelpCommand, but call the HTML-help directly. Because Application.HelpCommand isn't called anymore, neither is the OnHelp event (HelpCommand calls OnHelp). The only way to work around this problem seems to be to trap the WM_HELP at form level or change the delphi source code of TApplication.
Respond

RE: Doesn't work in Delphi 6
S Dingenouts (Jun 1 2002 5:51PM)

I meant change the source code of TCustomForm...
Respond

Does not work. Do you know why?
    Dave Murray (Mar 18 2002 11:01AM)

Sorry, there was a typo on that line from when I copied it into the article. That line has been changed and now reads:
  Application.OnHelp := HTMLHelper.ApplicationHelp;

Thanks,
Dave.
Respond

Does not work. Do you know why?
    Abilio Fernandes (Mar 15 2002 11:44PM)

Hi.
When I try this stuff in Delphi 4, I get an error on this line:

  Application.OnHelp := HTMLHelpUser.ApplicationHelp;

Delphi says: HTMLHelpUser non declared.

Any clues, anybody?
Thanks

topmaster@sitemania.com
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
S. Carter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)