# MX\_AUTOPARENT

> [HTML Version](mx_autoparent.htm)

_Rewritten June 2025_

**xcall MIAMEX, MX\_AUTOPARENT, newctrlid \{,oldctrlid\}**

MX\_AUTOPARENT (MIAMEX 141) allows you to query and/or set the default AUI parent control, which comes into play in the following circumstances:

•	Controls are created using [AUI\_CONTROL](aui_control.md) without explicitly specifying a parent in the parentid parameter.

•	Controls are created using [TPRINT/DPRINT/EPRINT](proportionalfonttextobjects.md) (which don't offer such an option)

•	Controls are created by [PRINT](printstatement.md) statements when [SET AUTOTPRINT](set_lit.md) is active

•	TAB(-1,0), TAB(-1,9) or TAB(-1,10) are used (potentially deleting controls from the parent window)

The main use case is to simplify dialog creation, allowing use of the simpler variations of PRINT statements instead of the more complex AUI\_CONTROL calls.

Note that while Groupbox controls (rather than dialogs) are not normally considered eligible default parents, there in an exception for xPRINT statements.  So for example, after creating a groupbox control and setting it to be the default parent control, you can then display text within the groupbox using PRINT TAB coordinates starting from (1,1). (And if you then change the coordinates of the groupbox, the contents will move with it.)

To avoid unexpected side effects, clear the auto parent setting when no longer needed by calling the routine with newctrlid set to 0. It will also be cleared automatically at the start of a new RUN program.

Unless specifically overridden via the parentid parameter passed to [AUI\_CONTROL](aui_control.md) when creating GUI objects, the normal default parent will be the current modal dialog (if there is one), else the main window.  to apply to subsequent TPRINT/DPRINT and Tab(-1,9) and Tab(-1,10) commands.  

Although you can accomplish the same result using the [AUI\_CONTROL](aui_control.md) functions and specifying the parent control explicitly, the MX\_AUTOPARENT function greatly simplifies dialog coding by allowing you to use the much simpler [TPRINT, DPRINT](proportionalfonttextobjects.md), and Tab(-1,9-10) commands. This is particularly true if [SET AUTOTPRINT](set_lit.md) is used to interpret existing PRINT statements as if they were TPRINT statements.

Note that MX\_AUTOPARENT will be automatically forwarded to the ATE client via AG\_AUTOPARENT.

**Parameters**

_newctrlid_  ([String](string.md)/[Num](num.md))  \[in\]

The alphanumeric control name or numeric ID of the new auto parent.  Must be set to "" if you just want to query the existing auto parent without changing it.

_oldctrlid  _(Num)  \[out\]

If specified, returns the numeric ID of the previous auto parent control.

**See Also**

•	[A-Shell](ashellsbr.md) (_pflag_ option related to autoparent)

**History**

2014 February, A-Shell 6.1.1374:  Add support for current and new auto parent.