ContentsIndexPreviousNext

5.1 The Components of a Control

This chapter begins with a detailed look at the components of ACUCOBOL-GT's graphical controls. Included is a description of the common and special properties of each control, along with the global style properties that are valid for all control types. The chapter concludes with reference entries for each control type.

To work efficiently with graphical controls, you need to be thoroughly familiar with the components of controls and their organization.

In most instances, controls are simple to create and manage. In some cases they are complex. In addition to the information in this chapter, information pertaining to controls is located in the following chapters and sections:

Chapter 3, "Graphical Controls"

This chapter provides an overview of controls and how they fit into the graphical environment. In addition, the chapter describes the use of the alternate character coordinate phrases, the creation and use of bitmap buttons, and the general use of paged list boxes and paged grids.

Chapter 4, section 4.4, "Styles and Special Properties" 4.4 Styles and Special Properties

This section describes how the compiler recognizes style and special property names based on the context in which they appear.

Book 3 (Reference Manual), Chapter 5, section 5.8, "Screen Section"

This section describes the Screen Section syntax used to create controls.

Book 3 (Reference Manual), Chapter 6, section 6.4.9, "Common Screen Options"

This chapter describes options that are common to Screen Section entries and the ACCEPT, DISPLAY, and MODIFY verbs. Included in this set are the phrases used to specify a control's common properties.

Book 3 (Reference Manual), Chapter 6, section 6.6, "DISPLAY Control-Type"

This section describes how the Format 14 DISPLAY Control-Type statement is used to create controls.

The remainder of this section focuses on control components, particularly their properties. At the end of this section you will find the Common Properties Table, Styles Table, and Special Properties Table. These tables provide a quick reference to control types and their properties.

Components

All controls have the following components:

Type

The compiler recognizes the following control types:

ACTIVE-X
BAR
BITMAP
CHECK BOX
COMBO BOX
ENTRY FIELD
FRAME
GRID
LABEL
LIST BOX
PUSH BUTTON
RADIO BUTTON
SCROLL BAR
STATUS BAR
TAB
TREE VIEW
WEB BROWSER

Control type names are reserved by the compiler.

Handle

When a control is created, a handle to the control is also created. This handle is a COBOL data item. Its value uniquely identifies the control to the system. Handle values are generated dynamically at runtime and cannot be controlled by the programmer.


Programmers note: If you want to assign a constant name to a control (a name that remains the same between runs), you can assign an ID to the control. Anytime the runtime returns information about a control, it includes both its handle and its ID. Because the handle can change from run to run, examining the ID can be more convenient. Note that using IDs is the only effective way to distinguish controls in the Screen Section, because those controls' handles are hidden from the programmer.
Properties

All components of a control, excluding the type and handle, are properties. Control properties are classified into two groups: common properties--those that apply to all types of controls--and special properties--those that are specific to a single type of control. Note, however, that some common properties have a special meaning (or no meaning) for some control types. In addition, some special properties are used by more than one control type. For example, the special properties that apply to bitmap buttons are used by push button, radio button, and check box controls.

Common Properties

Common properties that apply to virtually all controls include: location, size, title, value, color/intensity, font, style, visibility, useability (enabled/disabled), ID, and key.

The function and syntax of each common property is described in section 6.4.9, "Common Screen Options" in Book 3, "Reference Manual." Any further qualification of a common property for a specific control type is described in this chapter in the section that describes that control type.

Styles

STYLE is a common property. The STYLE property holds a numeric value. This value is the sum of the numeric values of the individual styles that have been applied to a particular control. Styles affect the appearance or behavior of a control. For example, some of the styles that apply to a radio button include: BITMAP, FRAMED, and NOTIFY. Individual styles have a predefined numeric value (assigned in the file "controls.def") and do not take any other value. A style can be applied or not applied. If the style is indicated in a statement, it is applied to the control; if it is absent, it is not applied. Most styles apply to only a certain type of control, although a few are common to all controls.

There are two ways to specify a style for a control.

1. Include the style name in the statement that creates the control.

2. Add the style's numeric value to any other style values that apply, and include the sum value in the STYLE IS style-flags phrase, where style-flags is the sum value.

Including the style name in the statement that creates the control is the usual method for specifying a style. The collection of style names included in the statement (such as "BITMAP" and "NOTIFY") instructs the compiler to build the appropriate STYLE property value (the STYLE property is technically the method by which all styles are stored in the runtime system). However, there is an important restriction: the compiler understands style names only when it knows what kind of control is being built. If you specify a control that has a variable (undefined) type, then you must specify styles with the "STYLE IS style-flags" phrase. In this case, you construct the STYLE property value by adding together the appropriate style numbers. Each style has a corresponding numeric value, and the STYLE property holds the sum of the specified styles. For example, if the numbers corresponding to BITMAP and NOTIFY were "1" and "4" respectively, then the phrase "STYLE IS 5" would specify those two styles. Each style's identifying number can be found in the file "controls.def" (they are level 78 items).

Special Properties

Each control defines its own set of special properties. Special properties are used to give a control a special attribute or capability. For example, an entry field can have the special properties MAX-TEXT, MAX-LINES, and CURSOR.

Special properties are specified with the PROPERTY and Property-Name phrases of the "DISPLAY Control-Type" statement (see section 6.6, Book 3, "Reference Manual"), or in a Format 2 Screen Section Entry. Note that the PROPERTY reserved word always refers to a special property.

All special properties require a value. For example MAX-TEXT takes a numeric value that specifies the maximum number of characters that can be entered in the field.


Note that in any statement in which control properties can be set (i.e., the Screen Section and the DISPLAY and MODIFY verbs), you can specify a list of property values in parentheses. This has the effect of setting the specified property to each value in the list, in turn. This is useful for the special properties that can have multiple settings. For example, you can assign the values "20" and "30" to the DATA-COLUMNS list box property with the following syntax:

DATA-COLUMNS ARE ( 20, 30 )

Also note that the optional word "ARE" is allowed in place of "IS" or "=" in the syntax.
Because control property values are set in the order specified, if you specify multiple values for a property that can take only a single value, the net effect is the same as setting the last value in the list.

More:

5.1.1 Control Components Diagram

5.1.2 Common Properties Table

5.1.3 Styles Table

5.1.4 Special Properties Table