One of the challenges in ATCG is finding the right references at replay time that correspond with the original controls at record time. For example, while recording, we find out about a new form when the Form class load event method is called. The reference to the form is the receiver of the method, so there is no mistake. However, at replay time, there may be several forms available from app.getForm with the same name, so we need to get the right one.
Dynamic controls is another example. The Control class loadControl method allows a control (usually a painted control) to be cloned and added to the form. The Form class addControl method allows any number of dynamically created controls to be added to the form. These new controls are created from scratch on the fly, and they may bear no resemblance to any existing control. Toolbars and navigation panes are frequently made up of these dynamic controls.
In the case of the form references, ATCG retrieves the references as the forms are opened, so they are kept straight. The app.getForm method returns the most recently opened form.
For references to controls that are loaded from painted controls, those are retrieved at replay time using the Control class getControl method. The correct index to use is captured at recording time.
There is no way to be certain about getting the correct references to controls that are added or those that are loaded from added controls. The current technique is to match them based on the following criteria of the control.
bubbleHelp text
name property value
Class name
left property value
For left‑aligned controls, the distance to the right edge of the parent
top property value
index property value
These criteria are all checked for the control, its parent control, the parent of its parent control, and so on, up to the form.
To allow for right‑aligned controls (for example, toolbars) where the form has been resized, it is considered a match if the value of the left property or the distance to the right edge of the parent matches.