Control - Command Button

images\btn_ctrl_button.gif Command buttons are used to issue commands in a form. The OK and Cancel buttons often seen in Windows dialogs are command buttons, for example.

 

To Add a Command button to a Form

 

1. Click on the Insert Command button button in the Tools toolbar.

2. Click and drag the location and size where it is to be created in the form.

3. Continue to create any additional command buttons desired.

4. Right click onto each command button and choose Properties from the context menu.

5. Set the properties for the command button as desired.

6. Move, resize and align the command button as desired.

 

Properties normally both return and set that particular property. The easiest way to edit properties is through the context menu's properties dialog for that control.

 

Some attributes of controls, such as their size or position are properties not of the control but of the container for the control, in this case the Form itself. To change the size or position of controls we can simply click on them and resize or drag them to a new position.

 

Keep in mind that programs can change the properties of controls at run time. Although this documentation is written as though the properties are set at design time using the Properties dialog for this control, there are many situations in which program code will be used to change a control's properties at run time.

 

Note: All properties and controls are prefaced with "wl" to indicate they are the windowless lightweight versions of the controls and properties settings. The "wl" prefix is suppressed in the documentation below to enhance legibility.

 

Properties

 

In addition to the properties listed below, a Control tab provides access to certain frequently used form properties for this control. See the Form Properties topic for information on those properties.

 

 

Command Button

General

 

Caption

Text used to label the command button. Font is set in the font tab.

MousePointer

The type of mouse pointer displayed when over the command button. Choose from 16 different types plus a custom pointer

Appearance

3D or Flat. 3D is the standard Windows look. Flat has no effect with command buttons.

OLEDropMode

Set to None (default) if the command button does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the command button will trigger OLE drop events, allowing programs to handle the OLE drop operation in code.

Style

Standard (default) or Graphical. In Standard style command buttons display as a button with the caption on top. In graphical style, command buttons may also display an associated graphic.

Enabled

True or False. True means the object can respond to user-generated events, false prevents it from responding. We can disable a control like a text box if we wish it to simply display information in a read-only way.

UseMaskColor

If checked, enables use of mask color in a button's picture if the Style is set to graphical. A mask color is the color that is to be made transparent.

 

 

Color

 

Back Color

Color to be used for the command button's background, normally seen only when Flat Style is used.

Fore Color

Color to be used for the command button's foreground, the color of the text caption.

Mask Color

Color to be treated as transparent in an image used with the button when UseMaskColor is checked and Style is set to graphical.

Color Set

Choose from Standard Colors (standard Windows non-dithered colors) or Windows System Colors. The latter will be defined by the user's Control Panel settings and is normally the setting used so that the form changes appearance like the rest of Windows if the Control Panel settings are changed.

Color Palette

Displays available colors. Click on the property to be changed to highlight it in the Properties pane, click on the desired color in the Color Palette pane and then press Apply.

Edit Custom Color

Change the custom color presented in the Color Palette when the Color Set is set to Windows System Colors.

 

 

Font

 

Properties

Font properties that may be changes.

Font

Choose a font installed on this system. It's wise to choose standard Windows fonts such as MS Sans Serif that are universally available.

Size

Size of font, in points.

Effects

Bold, Italic, Underline or Strikeout.

Sample Text

A preview of the selected settings.

 

 

Picture

 

DisabledPicture

Graphic to show when control is disabled if Style is set to graphical.

DownPicture

Graphic to show on an enabled control in the DOWN position if Style is set to graphical.

MouseIcon

Custom icon to use when the MousePointer property is set to 99. Like Visual Basic, will not load animated cursor (.ani) files.

Picture

Graphic to show on an enabled control in the UP position if Style is set to graphical.

 

 

 

Note: graphics are loaded at design time and saved within the project. When browsing to find the graphic to be used, .bmp, .ico, .wmf, .gif or .jpeg files may be used.