Microsoft Windows Architecture for Developers Training Kit
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
- In the Project's Properties, set the Help File Name property to WA\Practice\Ch12\Myhelp.hlp
- Set the frmChild HelpContextID property to 1 and cmdLoad HelpContextID property to 2.
- Save and run the application.
- Create a new child and press F1.
The context-sensitive Help describing a child form will be displayed.
- Close the Windows Help dialog.
- Press TAB to set focus on Load Picture .
- Press F1 again to open the context-sensitive Help describing the command button.
- 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
- Start Visual Basic and create a new standard EXE project.
- Insert a command button on Form1.
- Change the command button's Caption property to &Close.
- In the Command1_Click () event, type the following code:
Unload Me
- In the Form1_Load () event, type the following code:
Command1.ToolTipText = "This button will close the form!"
- From the Run menu, click Start.
- 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.
- 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:
- Set the HelpFile property to the .hlp file for this application.
- Select the control for which you want to provide help.
- In the Properties window, select the WhatsThisHelpID property.
- Enter a context ID number for the associated pop-up Help topic.
- Repeat steps 2 through 4 for any additional controls.
- Select the form.
- In the Properties window, set the Form's WhatsThisHelp property to True.
- 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.