|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
Adding Help Topics To The Help IndexYou can add a Help topic to the Help index by inserting a footnote with the custom mark K, giving that footnote the text you want to appear in the index. For example, we add the item File Menu Items to the Help index in Figure 30.12, by adding a footnote, K, to the appropriate Help page in helper.rtf. Now when the user uses the Help files index, the items weve added, such as File Menu Items and Help Menu Items, appear in that index, as shown in Figure 30.14. When the user clicks them, the Help system jumps to the matching page.
Creating Help Pop-Up LinksYou can create Help pop-ups, which work much like tool tips in a Visual Basic program. As an example, weve added the pop-up you see in Figure 30.15, which explains the term file with a pop-up. Pop-ups appear in Help files with a dotted underline; when the user clicks that pop-up, the associated text is displayed in a tool-tip-like window.
Adding a pop-up is just like adding a Help hotspot, but instead of double-underlining the hotspot, you just use a single underline. Lets see an example. Here, well create the pop-up you see at work in Figure 30.15. To do that, just underline the term you want to create a pop-up for, using the Visual Basic Format menu, and add the hidden text jump tag. Well use FILE_POPUP for the jump tag here, like this:
Open
Opens a fileFILE_POPUP.
----..........
Because weve used a single underline instead of a double one, the Help system will display the text that has the tag FILE_POPUP instead of actually jumping to that page. Well see how to create that page in the next topic. Creating Help Tool Tips TargetsTo create a target page for a Help pop-up, you use footnotes with the custom mark #, just as you would for any Help hotspot. To complete the example we started in the previous topic, we add a new page to our helper examples RTF file with the footnote # and the footnote text FILE_POPUP, as shown in Figure 30.16.
Finally, we place the text we want to display when the pop-up appears into the new page, as also shown in Figure 30.16. Now when the user clicks the underlined item in the Help system, the pop-up will appear, as shown in Figure 30.15. Compiling Help Files With The Help WorkshopNow that youve created your RTF file with the Help text and hotspots you want to use, along with your Help project in the Help Workshop, how do you create the actual HLP file? You use the Help Workshops Compile item in the File menu. That menu item brings up the Compile A Help File dialog box you see in Figure 30.17; click Compile to create the Help file, which in the case of the example weve developed over the previous few topics is helper.hlp.
Congratulationsyouve created a new Help file. But how do you launch it from Visual Basic? Well look at that next. Displaying A Help File From Visual BasicThe Testing Department is calling. Your new Help file is very helpful, but now youve got to display it from your Visual Basic application. Makes sense, you think, but how do you do that? To display a Help file from a Visual Basic program, you can use the Windows API function WinHelp:
Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal_
hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long,_
ByVal dwData As Long) As Long
Heres what the arguments to this function mean:
Here are the possible values you can use for the wCommand argument:
Lets see an example. Here, well open the helper.hlp Help file in an application named helper when the user selects the Help item in the applications Help menu. To start, we declare WinHelp and the constants it can use:
Const HELP_CONTEXT = &H1
Const HELP_QUIT = &H2
Const HELP_INDEX = &H3
Const HELP_CONTENTS = &H3&
Const HELP_HELPONHELP = &H4
Const HELP_SETINDEX = &H5
Const HELP_SETCONTENTS = &H5&
Const HELP_CONTEXTPOPUP = &H8&
Const HELP_FORCEFILE = &H9&
Const HELP_KEY = &H101
Const HELP_COMMAND = &H102&
Const HELP_PARTIALKEY = &H105&
Const HELP_MULTIKEY = &H201&
Const HELP_SETWINPOS = &H203&
Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal_
hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long,_
ByVal dwData As Long) As Long
Then, when the user selects the appropriate menu item, we display the helper.hlp file with WinHelp this way:
Private Sub mnuHelp_Click()
retVal = WinHelp(Form1.hwnd, "c:\vbbb\helper\helper.hlp",_
HELP_INDEX, CLng(0))
End Sub
And thats itnow the user can open the helper.hlp file from the Visual Basic helper application, as shown in Figure 30.18.
Now were supporting Help files in our Visual Basic applications. The code for this example is located in the helper folder on this books accompanying CD-ROM.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |