Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Showing Windows Help From A Visual Basic Program

You can display a Windows Help file (.hlp) with the Common Dialog control’s ShowHelp method. To use this method, you first set the Common Dialog control’s HelpCommand property to one of the following settings, and the HelpFile property to the actual name of the Help file to open.

Here are the possible settings for HelpCommand:

  cdlHelpCommand—&H102&; executes a Help macro.
  cdlHelpContents—&H3&; displays the Help contents topic as defined by the Contents option in the [OPTION] section of the HPJ file. This constant doesn’t work for Help files created with Microsoft Help Workshop Version 4.0X. Instead, you use the value &HB to get the same effect.
  cdlHelpContext—&H1&; displays Help for a particular context. When using this setting, you must also specify a context using the HelpContext property.
  cdlHelpContextPopup—&H8&; displays in a pop-up window a particular Help topic identified by a context number defined in the [MAP] section of the HPJ file.
  cdlHelpForceFile—&H9&; ensures WinHelp displays the correct Help file. If the correct Help file is currently displayed, no action occurs. If the incorrect Help file is displayed, WinHelp opens the correct file.
  cdlHelpHelpOnHelp—&H4&; displays Help for using the Help application itself.
  cdlHelpIndex—&H3&; displays the index of the specified Help file. An application should use this value only for a Help file with a single index.
  cdlHelpKey—&H101&; displays Help for a particular keyword. When using this setting, you must also specify a keyword using the HelpKey property.
  cdlHelpPartialKey—&H105&; displays the topic found in the keyword list that matches the keyword passed in the dwData parameter if there is one exact match.
  cdlHelpQuit—&H2&; notifies the Help application that the specified Help file is no longer in use.
  cdlHelpSetContents—&H5&; determines which contents topic is displayed when a user presses the F1 key.
  cdlHelpSetIndex—&H5&; sets the context specified by the HelpContext property as the current index for the Help file specified by the HelpFile property. This index remains current until the user accesses a different Help file. Use this value only for Help files with more than one index.

Often, you want to open a Help file to its contents page, and so you’d set the HelpCommand property to the cdlHelpContents constant. Be careful, however, that constant doesn’t work with some Help files (those constructed with the Microsoft Help Workshop Version 4.0X), so check if ShowHelp works properly before releasing your program. The cdlHelpContents constant works with fewer Help files than you might think—in fact, it won’t open the main Windows Help file itself, windows.hlp, correctly. Instead, you must use a special value, &HB:

Private Sub Command1_Click()
    CommonDialog1.HelpCommand = &HB
    CommonDialog1.HelpFile = "c:\windows\help\windows.hlp"
    CommonDialog1.ShowHelp
End Sub

The result of this code appears in Figure 11.13. Here, we’re opening the Windows main Help file to its contents page.


Figure 11.13  Opening Windows Help from a Visual Basic program.

Our ShowHelp example is a success. The code for this example is located in the helpdialog folder on this book’s accompanying CD-ROM.


Previous Table of Contents Next


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.