Please enable JavaScript to view this site.

ASQL Reference

Navigation: » No topics above this level «

Add Control

Scroll Prev Top Next More

Rewritten Feburary 2013

To add or create a control, use CTLOP_ADD and specify at least all the parameters up through the ecol parameter. The rest are optional.

The following simple example creates a button occupying the rectangle from 5,10 to 6,20 (in the grid units of the current parent window), displaying "Process", and transmitting exitcode -107 when clicked:

xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid, "Process", MBST_ENABLE, MBF_BUTTON + MBF_KBD, "VK_xF107", "", cstatus, 5, 10, 6, 20

In this slightly more complex example, we create a clickable static text control, specifying an alphanumeric id and a variety of other attributes. See Comments.

fontattr = FS_ITALIC + FA_HEAVY

fontscale = 250

fontface$ = "Impact"

tooltip$ = "Click for more information"

parentid$ = "gbMessages"

xcall AUI, AUI_CONTROL, CTLOP_ADD, "txtWarning", "Warning! Meltdown Imminent!", MBST_ENABLE, MBF_STATIC + MBF_LFJUST + MBF_AUTOGROW + MBF_KBD, "VK_xF108", NUL_FUNC$, NUL_CSTATUS, 2, 10, 3, 20, &h0000ff, RGB_TRANSPARENT, fontattr, fontscale, fontface$, tooltip$, parentid$

 

Comments

If the ctlid parameter is numeric, it is ignored on input and set to the new control's numeric id on output. But if ctlid is alphanumeric, it is used as-is, and does not change. The numeric equivalent (or an error code < 0) will be returned in the cstatus parameter, assuming the parameter is numeric. The second example uses NUL_CSTATUS, defined as "" in ashell.def, which eliminates the return status; this is a significant performance optimization in the case of ATE where each control created would otherwise require waiting for the client's return status packet to arrive before the next control could be created.
If the parentid parameter is not specified, as in the first example, the new control will be a child of the current window: either a modal dialog, if one exists, or else the main window. The coordinates specified will be taken as relative to the parent control.
For most child controls, if the new control has the same starting position as an existing child control, the existing control will be removed. In the case of the GUI_SPC_IND system option, this rule is expanded slightly to allow a new control to replace a pre-existing one that overlaps the new one. In both cases, the intent is to simplify automated strategies for migrating from plain text to GUI. See AUTOTPRINT, MX_DEFTABXYZ, and INFLD's type |G).
Normally, the control type is determined by the ctype parameter, but in certain circumstances you can set ctype to 0 and specify the control type in the winclass, winstyle, and winstylex parameters. This technique is generally only useful for control types that do not require any interactivity -besides a click action), with the main example being Lines, Rectangles and Frames, although it may also provide a way to create a control type for which no ctype flags have been defined.