Delphi Programming for the HTML Help API N Page 1
Total Page:16
File Type:pdf, Size:1020Kb
Delphi Programming for the HTML Help API n Page 1 A Help Think Press Publication Delphi Programming for the HTML Help API by Robert Chandler The Helpware Group http://www.helpware.net Help Think Press A Division of Work Write, Inc. 128 South Eastview Avenue Feasterville, PA 19053 USA Tel: +1 215.357.3453 Web: http://www.workwrite.com/ helpthink/welcome.htm Email: [email protected] Copyright 2001, Help Think Press/Work Write, Inc. All rights reserved. Delphi Programming for the HTML Help API n Page 2 Copyright © 2002, Work Write, Inc. All Rights Reserved. This document is the sole property of Work Write, Inc. and is protected in its entirety by copyright law. You must tread this document as you would any other copyrighted material, such as a book. Limitation of liability No patent liability is assumed with respect to the use of the information contained herein or accompanying sample files. Although every precaution has been taken in the preparation of these materials, the publisher/author assumes no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Cheryl Lockett Zubak/ Work Write, Inc./Help Think Press cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. The publisher welcomes your feedback This document is published by Help Think Press, a division of Work Write, Inc. Work Write, Inc. Work Write, Inc. specializes in the development of hypertext user assistance as well as training on authoring tools and help design. (For more information, see “About the pubisher” at the end of this document.) Help Think Press welcomes (truly! no kidding!) your comments on these materials and, if we find them to be valid, will make every effort to incorporate them into the next edition. You can reach Cheryl Lockett Zubak at Work Write, Inc., 128 South Eastview Avenue, Feasterville, PA 19053 USA. Phone: +1 (215) 357-3453; fax +1 (215) 357-0695; email [email protected]; website http://www.workwrite.com. Copyright 2001, Help Think Press/Work Write, Inc. All rights reserved. Delphi Programming for the HTML Help API n Page 3 Table of contents Title page .................................................................................. 1 Copyright . ................................................................................ 2 Introduction ..............................................................................5 Examples and source code ...........................................................6 Getting started...........................................................................7 Connecting to the API ..................................................................8 Static versus dynamic loading ................................................................. 8 Static loading ....................................................................................... 9 Dynamic loading ..................................................................................10 The HtmlHelp() API function ................................................................... 12 Examples using HtmlHelp() .................................................................... 14 Basic help commands .................................................................15 A warning about closing help ................................................................. 15 Displaying a help topic.......................................................................... 16 Displaying help using help context IDs .................................................... 17 Defining the context ID (topic mapping) .................................................. 17 The Delphi side of context help ............................................................... 18 Moving from WinHelp to HTML Help ..............................................19 Hooking help calls ................................................................................ 19 Programming “What’s This” help ............................................................ 21 HTML Help popups ............................................................................... 24 Other HTML Help Programming Issues .......................................... 28 Isolating the application from the API ..................................................... 28 Delphi 3 COM DLL bug........................................................................... 29 Launching HTML Help from a second application ...................................... 30 Free Delphi code (Woo hoo!) ........................................................31 HH.pas ................................................................................................ 31 HH_Funcs.pas ...................................................................................... 31 Other HH API commands ............................................................ 32 Code Example 4................................................................................... 32 The Contents, Search and Index tabs ...................................................... 32 Get Last HTML Help error ....................................................................... 34 Keyword searches ................................................................................ 35 Synching the Contents tab .................................................................... 36 Getting the window handle ................................................................... 36 Programming HH window types ............................................................. 36 Copyright 2001, Help Think Press/Work Write, Inc. All rights reserved. Delphi Programming for the HTML Help API n Page 4 Bridging the gap between help and the application ..............................................................41 HTML Help notification messages................................................. 42 Enabling notification messages ............................................................. 43 Receiving notification messages ............................................................ 43 HTML Help training cards ........................................................... 45 Setting up training cards ...................................................................... 45 Responding to a WM_TCARD ................................................................. 46 Embedding the WebBrowser control ............................................ 47 Importing the WebBrowser ActiveX control .............................................. 48 Programming the WebBrowser control .................................................... 49 Embedding HTML Help...............................................................50 How it’s done ...................................................................................... 50 Extending HTML Help using COM ................................................. 53 Calling the automation server................................................................ 53 Creating the automation server ............................................................. 54 Register a COM control as safe ............................................................... 56 Extending HTML Help using KeyHelp ............................................ 57 Reading the contents of a CHM file .............................................. 57 A few final remarks ................................................................... 58 About the author, Roboert Chandler ....................................................... 58 About the publisher, Help Think Press ..................................................... 58 Appendix 1 .............................................................................. 59 Copyright 2001, Help Think Press/Work Write, Inc. All rights reserved. Delphi Programming for the HTML Help API n Page 5 A Help Think Press Publication Delphi Programming for the HTML Help API by Robert Chandler The Helpware Group http://www.helpware.net his chapter covers HTML Help programming using Borland’s 32-bit Delphi T(i.e., Delphi 2 and above). While Delphi does not support HTML Help directly, Delphi is a very rich and flexible programming environment. We will see that it takes very little effort to convert our WinHelp Delphi appli- cations to HTML Help. The chapter assumes that you have a basic working knowledge of Delphi programming and have glanced at the HTML Help API reference in the Microsoft HTML Help Workshop online help. In this chapter, we will cover such subjects as: u Connecting to the API u Basic help commands This document and accompanying sample files were developed under contract to: u Moving from WinHelp to HTML Help Help Think Press A Division of Work Write, Inc. u Understanding HTML Help programming issues and API commands http://www.workwrite.com/ helpthink/welcome.htm u Reviewing the free Delphi code Copyright © 2002, Help Think Press/Work Write, Inc. All rights reserved. u Connecting HTML Help systems with your Delphi program Copyright 2001, Help Think Press/Work Write, Inc. All rights reserved. Delphi Programming for the HTML Help API n Page 6 Examples and source code If you haven’t yet installed the HTML Help Workshop, you should do so, since it includes detailed documentation on programming the HTML Help API. You can download it from: http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconHH1Start.asp