Implementing Help in an Application

Add Context-Sensitive Help to an Application

In this exercise, you will add context-sensitive Help to your MDI application.

* To add context-sensitive Help

  1. In the Project's Properties, set the Help File Name property to WA\Practice\Ch12\Myhelp.hlp
  2. Set the frmChild HelpContextID property to 1 and cmdLoad HelpContextID property to 2.
  3. Save and run the application.
  4. Create a new child and press F1.

    The context-sensitive Help describing a child form will be displayed.

  5. Close the Windows Help dialog.
  6. Press TAB to set focus on Load Picture .
  7. Press F1 again to open the context-sensitive Help describing the command button.
  8. Stop the application.

ToolTips

ToolTips are an effective way to display information to the user as they navigate the user interface. A ToolTip is a small label, usually containing a description of the control's function, which is displayed when the mouse pointer is held over a control for a set length of time. Normally used in conjunction with toolbars , ToolTips also work well in most parts of the interface.

Most Visual Basic controls contain a single property, called ToolTipText, for displaying ToolTips.

Example

This example implements a ToolTip for a command button named cmdPrint :

 cmdPrint.ToolTipText = "Prints the current document" 

As with other parts of the interface, make sure that the text clearly conveys the intended message to the user.

* To create a ToolTip in Visual Basic

  1. Start Visual Basic and create a new standard EXE project.
  2. Insert a command button on Form1.
  3. Change the command button's Caption property to &Close.
  4. In the Command1_Click () event, type the following code:
     Unload Me 
  5. In the Form1_Load () event, type the following code:
     Command1.ToolTipText = "This button will close the form!" 
  6. From the Run menu, click Start.
  7. Position your mouse pointer over the Close button on the form.

    Notice that the tool tip will display a message describing what functionality the command button provides.

  8. Click Close and exit Visual Basic.

Note

To learn more about ToolTips, see "ToolTipText Property" in the Language Reference in Visual Basic Books Online.


What's This? Help

What's This? Help provides a link to a pop-up Help topic. It is implemented when the user selects What's This? Help and clicks the What's This? cursor on a control. What's This? Help can be initiated from a toolbar button, a menu item, or a button on the title bar of a dialog box.

To enable What's This? Help from a Visual Basic menu or toolbar:

  1. Set the HelpFile property to the .hlp file for this application.
  2. Select the control for which you want to provide help.
  3. In the Properties window, select the WhatsThisHelpID property.
  4. Enter a context ID number for the associated pop-up Help topic.
  5. Repeat steps 2 through 4 for any additional controls.
  6. Select the form.
  7. In the Properties window, set the Form's WhatsThisHelp property to True.
  8. In the Click event of the menu or toolbar button, enter the following:
      formname  .WhatsThisHelp 
When the user clicks the button or menu, the mouse pointer changes to the What's This pointer.

In Visual Basic, to enable What's This? Help on the title bar of a custom dialog form, the WhatsThisHelp property must be True for the WhatsThisButton property to be True . In addition, the following properties also must be set:


Property Setting
ControlBox True
BorderStyle Fixed Single or Sizable
MinButton and MaxButton False
-or-  
BorderStyle Fixed Dialog


Note

To learn more about What's This? Help, see "WhatsThisHelp Property" and "WhatsThisButton Property" in the Language Reference in Visual Basic Books Online.




Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net