There is a uniform syntax for creating all of the visual objects:

CREATE object-type handle [ IN WIDGET-POOL pool-name ]

[ ASSIGN attribute = attribute-value [ attribute = attribute-value ] . . . ]
[ trigger-phrase ] .

When you create an object dynamically you must associate it with a HANDLE variable (or possibly a handle field in a temp-table). This is the only way to reference the object after you create it. Unlike a static object, it has no name.

The WIDGET-POOL phrase lets you define a special storage area in memory where you want the object’s description to be located. Use named widget pools describes this phrase in more detail.

Assign object attributes

The optional ASSIGN phrase allows you to assign one or more attribute values for the object at the time you create it. The attribute-value for each attribute can be a constant or it can be an expression. You can use the same CREATE statement for multiple objects of the same type that need to have different attribute values. Alternatively, you can assign attribute values after you create the object by using this syntax:

handle:attribute = attribute-value

The attributes you can assign to a dynamic object are largely the same as those you can assign in a static definition. You can find a complete list of all the attributes supported by each object in the ABL Reference, under the Widget Reference (for example, Button Widget). In the description of many of these attributes, there are one or more special restrictions attached to the attribute:

  • Readable only — These attributes can be read and used in expressions using the handle:attribute syntax, but their values cannot be assigned. In some cases, this is because the attribute value is part of the definition of the object and it would not make sense to change it. Examples of these attributes are:
    • DYNAMIC — Always true for dynamic objects and always false for static objects
    • HANDLE — Holds the value of the object’s handle
    • TYPE — Evaluates to the object-type

    In other cases, an attribute value cannot be assigned directly because it is set indirectly using some other method or statement. For example, most visual objects have a TAB-POSITION object, which holds the sequential position of the object within its frame. You cannot set this directly, but rather you must use the MOVE-BEFORE-TAB-ITEM or MOVE-AFTER-TAB-ITEM methods on an object to change its tab position, which is then reflected in the value of its TAB-POSITION attribute.

  • Can be set only before the widget is realized — You learned about realized objects in Define Graphical Objects. Some attribute values cannot be changed after the object has been realized. An example of this is the DEFAULT attribute for a button. The default button for a frame is the button that receives a RETURN event for its frame when the user presses RETURN or ENTER, which in turn executes its CHOOSE trigger. Once a button has been established as the default button for the frame and the button has been realized, when the frame is viewed, this attribute cannot be changed.
  • Graphical interfaces only — ABL supports most visual objects in character environments as well as GUI, but some object attributes can only be supported in graphical interfaces. An example is the BGCOLOR (background color) of a fill-in field. A fill-in field in a character environment does not use this attribute.
  • Character interfaces only — Likewise, some attributes are supported only in character interfaces. An example is the DCOLOR (display color) of a button or other visual object.
  • Windows only — ABL today supports a graphical interface only for the Microsoft Windows platform, so effectively any attributes marked as Windows only are the same as graphical interfaces only.

Assign triggers to a dynamic object

You can assign one or more triggers to the object using the optional trigger-phrase, in the same way as you did for static objects in Use Graphical Objects in Your Interface.