Subroutines > Detailed Descriptions > AUI > Control > AUI_Control Parameters > opcode

Add Control

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

A simple example would be creating a button occupying the rectangle from (5,10) to (6,20), displaying “OK”, and transmitting the equivalent of the F2 key when clicked:

xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid, "ok", MBST_ENABLE, MBF_BUTTON + MBF_KBD, "%VK_F2%", "", cstatus, 5, 10, 6, 20

The ctlid is ignored on input and set on output (unless it is an alphanumeric Control Name). cstatus is set >= 0 to indicate success or <0 for error. If you are not interested in the returned ctlid or cstatus, you can specify a literal 0 for ctype and a string (rather than numeric variable) for cstatus. (This may be appropriate where there is little doubt that the operation will succeed, and you are not storing the ctlid anyway. The main advantage of this technique is in UNIX environments, where it eliminates the need for the server to wait for a response from the ATE client, thus speeding up the operation of creating controls, particularly over slow connections. (See CTLOP_SBCH below for another optimization technique.) An example is given below.

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.