Making Controls Easier to Use

You want to make it as easy as possible for users to understand and use your controls. Access keys, tab order, ToolTip text, and selective disabling all contribute to a more usable design.

Setting Access Keys

An access key makes it possible for a user to choose a control from anywhere in the form by pressing ALT and the key.

To specify an access key for a control

  • Precede the desired letter in the Caption property for the control with a backslash and a less than sign (\<).

For example, the following property setting for the Caption of a command button makes O the access key.

\<Open

A user can choose the command button from anywhere in the form by pressing ALT+O.

To specify an access key for a text box or edit box

  1. Create a label with a backslash and less than sign (\<) in front of the desired letter, such as C\<ustomer.
  2. Make sure the label is the control in the tab order immediately preceding the text box or edit box you want to receive the focus.

Setting the Tab Order of Controls

The default tab order of controls on your form is the order in which you added the controls to the form.

Tip   Set the tab order of controls so that the user can easily move through your controls in a logical order.

To change the tab order of controls

  1. In the Form Designer toolbar, choose Set Tab Order.
  2. Double-click the box next to the control you want to have the initial focus when the form opens.
  3. Click the box next to the other controls in the order you want them to be tabbed to.
  4. Click anywhere outside the tab order boxes to finish.

You also can set the tab order for the objects on your form by list, depending on the setting in the Form Design tab of the Options dialog box.

You can set the selection order for the option and command buttons within a control group. To move to a control group with the keyboard, a user tabs to the first button in the control group and then uses the arrow keys to select other buttons in the group.

To change the selection order of buttons within a control group

  1. In the Properties window, select the group in the Object list. A thick border indicates that the group is in edit mode.
  2. Select the Form Designer window.
  3. From the View menu, choose Tab Order.
  4. Set the selection order as you would the tab order for controls.

Setting ToolTip Text

Each control has a ToolTipText property that makes it possible for you to specify the text displayed when the user pauses the mouse pointer over the control. Tips are especially useful for buttons with icons instead of text.

To specify ToolTip text

  • In the Properties window, select the ToolTipText property and type the desired text.

The form's ShowTips property determines whether ToolTip text is displayed.

Change the Mouse Pointer Display

You can change the mouse pointer display to provide visual clues to your users about different states your application might be in.

For example, in the tsBaseForm class of the Tasmanian Traders sample application, a WaitMode method changes the mouse pointer to the default wait state cursor. Before running any code that might take a while to process, the Tasmanian Traders application passes a value of true (.T.) to the WaitMode method to change the pointer and let the user know that processing is going on. After the processing is completed, a call to WaitMode with false (.F.) restores the default mouse pointer.

* WaitMode Method of tsBaseForm class
LPARAMETERS tlWaitMode

lnMousePointer = IIF(tlWaitMode, MOUSE_HOURGLASS, MOUSE_DEFAULT)
THISFORM.MousePointer = lnMousePointer
THISFORM.SetAll('MousePointer', lnMousePointer)

If you want to change the mouse pointer to something other than one of the default pointers, set the MousePointer Property to 99 - Custom and set the MousePointer Property to your own cursor (.cur) or icon (.ico) file.

Enabling and Disabling Controls

Set a control's Enabled property to false (.F.) if the functionality of the control is not available in a given situation.

Enabling and Disabling Buttons in a Group

You can enable or disable individual option buttons or command buttons in a group by setting the Enabled property of each button to either true (.T.) or false (.F.). You also can disable or enable all the buttons in a group by setting the Enabled property of the group, as in the following line of code:

frmForm1.cmgCommandGroup1.Enabled = .T.

When you set the Enabled property of an option button group or a command button group to false (.F.), all the buttons in the group are disabled, but will not be displayed with the disabled ForeColor and BackColor. Setting the Enabled property of the group does not change the Enabled property of the individual buttons in the group. This makes it possible for you to disable a group of buttons with some of the buttons already disabled. When you enable the group, buttons that were originally disabled remain disabled.

If you want to disable all the buttons in a group so that they appear disabled, and if you do not want to preserve information about which buttons were originally disabled or enabled, you can use the SetAll method of the group, like this:

frmForm1.opgOptionGroup1.SetAll("Enabled", .F.)

See Also

Displaying Controls in Grid Columns | Extending Forms | Using Controls | Caption property | Properties window | Controls and Objects