Partager via


How to: Make Controls Easier to Use

You can make the application user interface easier to understand and use by creating access keys, setting tab order, displaying ToolTip text and deactivating selected controls.

Creating Access Keys

You can create access keys so that users can choose a control from anywhere in the form by pressing ALT and the key.

To specify an access key for a control

  • In the Caption property for the control, precede the desired letter with a backslash (\) followed immediately by a left angle bracket (<).

For more information, see Caption Property (Visual FoxPro).

For example, the following setting for the Caption property of a command button creates an access key using the letter "O":

Caption = "\<Open"

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

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

  1. Create a label containing a backslash (\) and a left angle bracket (<) preceding the desired letter, for example, 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 Tab Order for Controls

The default tab order of controls on your form is set to the order in which you added the controls to the form. You can reset the tab order so that the user can traverse controls in a more logical order.

To change tab order for controls

  1. Open the form in the Form Designer.

  2. On the View menu, point to Tab Order, and click Assign Interactively.

    Tip

    You can also click Set Tab Order on the Form Designer toolbar. To set the tab order using a list, click Assign by List.

  3. Double-click the numbered box next to the control you want to have the initial focus when the form opens.

  4. Click the numbered box next to the other controls in the order you want them to be tabbed to.

  5. When you are finished, click anywhere outside the numbered boxes..

You also can set the default method to assign tab order using a list by setting the Tab ordering option on the Forms tab in the Options Dialog Box (Visual FoxPro).

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 (Visual FoxPro), 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

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

Changing the Mouse Pointer Display

You can provide visual clues about the different states your application might be in by changing how the mouse pointer displays.

To change the mouse pointer display

  • Create a method that changes the mouse pointer to a different state.

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 MouseIcon property to your own cursor (.cur) or icon (.ico) file. For more information, see MousePointer Property and MouseIcon Property.

Activating and Disabling Controls

You can activate or disable controls if they are not available under certain conditions.

To activate or disable a control

  • Set the Enabled property for the control to False (.F.).

For more information, see Enabled Property (Visual FoxPro).

You can activate or disable individual option buttons or command buttons in a group by setting the Enabled property for each button to 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

Tasks

How to: Display Controls in Grid Columns

Concepts

Controls and Objects Created in Earlier Versions

Reference

Controls for Extending Forms

Caption Property (Visual FoxPro)

Properties Window (Visual FoxPro)

Other Resources

Using Controls