Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 7

Providing WhatsThisHelp in an Application

When ToolTips don't provide enough information and you don't want to force the user to toggle between a Help file and your application, Visual Basic provides another means of displaying tips to the user.

WhatsThisHelp gives the means to pop-up information from the App.HelpFile object to the user in the same format used by ToolTips (see Figure 7.5).

Unlike ToolTips, WhatsThisHelp gets the pop-up information from a topic within a Help file so more extensive explanations of objects can be provided. Also, unlike context-sensitive Help discussed earlier in the chapter, the Help file does not open in a separate window. WhatsThisHelp pops up for the user and is visible only until the user clicks on the application window again.

WhatsThisHelp as it appears in a Visual Basic application. Note the similarity to ToolTips
FIGURE 7.5 WhatsThisHelp as it appears in a Visual Basic application. Note the similarity to ToolTips.

WhatsThisHelp Property

WhatsThisHelp usually functions on the form level in Visual Basic. The user typically invokes WhatsThisHelp by clicking on a menu item on the form and then by selecting the object for which help is desired.

If the developer wants to implement WhatsThisHelp on a form, the WhatsThisHelp property of the form must be set to True. This is done by the developer at design time.

The WhatsThisHelp property has to be set to True for any of the WhatsThisHelp methods discussed in this section to work.

WhatsThisMode Method

After you have decided to implement WhatsThisHelp on a form, you must provide a means for the user to invoke the pop-up information. The WhatsThisMode method of a form will start the process of WhatsThisHelp in an application.

If you provide a WhatsThis menu item, the code to do this would be in the Click event procedure of the WhatsThis menu item and would look something like this (assuming the WhatsThisHelp property of Form1 is set to True):

Form1.WhatsThisMode

Invoking the WhatsThisMode method will automatically change the appearance of the mouse pointer to let the user know that normal actions have been suspended while in the Help mode (see Figure 7.6). The mouse pointer remains like this until the user clicks on an object on the form.

The WhatsThisHelp mouse pointer.
FIGURE 7.6 The WhatsThisHelp mouse pointer.

WhatsThisHelpID Property

After WhatsThisHelp has been invoked and the WhatsThis mouse pointer is showing (refer again to Figure 7.6), the user can select an object on the form to get help for that object. When this happens, Windows uses the WhatsThisHelpID of the object to determine what information will be displayed. The WhatsThisHelpID maps to a topic in a Help file in the same way that a HelpContextID does. The only difference is that with the WhatsThisHelpID, the Help information appears in a pop-up window and not in a separate dialog box. As soon as the user clicks again in the application, the pop-up window goes away.

WhatsThisButton Property

A second way of invoking WhatsThisHelp is from a button on the title bar of a form, as shown in Figure 7.7. If you set the WhatsThisButton property to True, you will not need to invoke the WhatsThisMode method as described earlier. Instead Windows controls the invocation of Help mode.

A WhatsThisButton on the title bar of a form
FIGURE 7.7 A WhatsThisButton on the title bar of a form.

The following conditions must be true for the WhatsThisButton to appear on a title bar:

  1. The WhatsThisHelp property of the form must be True, and one of the following must be set:

    • The ControlBox property of the form must be True.
    • The MinButton and MaxButton properties of the form must be False.
    • The Borderstyle of the form must be either Fixed Single or Sizeable.

  2. The BorderStyle of the form must be Fixed Dialog if it is not Fixed Single or Sizeable.

If any of the three conditions above are not met, the WhatsThisButton will not appear for the form.

The WhatsThisHelp and WhatsThisButton properties of the form can only be written at design time. They're available at runtime as readonly properties.

ShowWhatsThis Method

The third way of displaying WhatsThisHelp in an application is by using the ShowWhatsThis method of a control. Code such as

Command1.ShowWhatsThis

will show help for the topic defined by the property Command1. WhatsThisHelpID. For ShowWhatsThis, the user does not have to click on the WhatsThisButton on the title bar or select a menu item to go into WhatsThis mode. You simply cause the WhatsThisHelp topic for the given object to appear by calling it up in your code.

Show WhatsThis is usually invoked with a right-mouse pop-up menu on a control.

As with the other methods of showing WhatsThisHelp, the WhatsThisHelp property of the form containing the controls with WhatsThisHelp must be set to True.

NOTE : WhatsThisHelp Topics in an HTML Help Project - As discussed later in this chapter under the section "HTML Help Source files for WhatsThisHelp," WhatsThisHelp topics do not look the same to a Help file developer as extended topics used with HelpContextIDs.

WhatsThisHelp topics from a WinHelp file, on the other hand, are the same in the WinHelp project as extended topics used with HelpContextIDs. However, as noted earlier, the VB programmer using a Help file sees no difference here. To the VB programmer, it is all a matter of using the HelpContextID property or the WhatsThisHelpID property, regardless of the format of the Help file.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved