CTLOP_CHG (opcode 2) can be used to change the text of a control, the command associated with it, or the state (enable/disable). For example, consider the following sample dialog:

If the data fields were blank, the “Delete” button should probably be disabled (since there would be nothing to delete). To do that, we can use opcode 2, as shown below. Note that for the purposes of this example, we will assume that the variable BTNID(2) had been previously set to the ctlid for the “Delete” button.
xcall AUI, AUI_CONTROL, CTLOP_CHG, BTNID(2), "", MBST_DISABLE
In the example above, we used the MBST_DISABLE value in the cstate parameter to change the state of the button to disabled. With this flag, no other changes are made to the control, so we do not need to worry about inadvertently changing the ctext and cmd parameters. The resulting dialog would look like this:

However, if we wanted to change the text of one of the controls (for example, changing the “Cancel” button to say “Surprise!” instead), we would need to use the MBST_CHANGE flag and set ctext accordingly:
xcall AUI, AUI_CONTROL, CTLOP_CHG, BTNID(4), "Surprise!", MBST_ENABLE + MBST_CHANGE
The result is:

Comments
• CTLOP_CHG with the MBST_POS state flag to resize or reposition a control now (as of A-Shell 1143 of April 2009) works with dialogs. Note that resizing the dialog this way does not automatically resize or reposition the controls within the dialog (relative to the dialog upper left corner).
• Get Control ID for another example scenario in which an EDIT (INFLD) control is enabled or disabled based on the state of a radio button.