I have found that it is better to be active, than reactive, whether dealing with a parent or child object. Identifying an object by 'waiting' using either the default timeout of the 'Exists' method, or explicitly specifying timeout values via the WaitProperty method is very reactive. In either case, rather than using some arbitrary timeout value, TestComplete provides the Sys process list to find a parent object, or the object list for child objects. Thus, I find it more economical to use a loop limited by a max count and a finite delay (999 milliseconds for example) to identify an object's parent then use methods such as the FindChild or FindAllChildren methods to ensure I am dealing with the correct object.
''' <summary>FindChildDialog</summary>
''' <param Type="String">[ByVal] parentName</param>
''' <param Type="String">[ByVal] wndCaption</param>
''' <param Type="Interger">[ByVal] intMax</param>
''' <returns type="Boolean">True if successful, otherwsie False</remarks>
''' <remarks>Search for child dialog with specified caption. Function fails if
''' the requried child is not located within the max number of retries</remarks>
Function FindChildDialog(parentName, caption, intMax)
FindChildDialog = False
Dim parent, dlg, dlgs, i, msg, wndCaption
Dim count : count = 0
Dim delay : delay = 999
Dim wndClass : wndClass = "WindowsForms10.Window.8.app.*"
Do
Sys.Refresh
Set parent = Sys.WaitProcess(parentName, delay)
If parent.WaitProperty("Exists", True, delay) Then
parent.Refresh()
dlgs = parent.FindAllChildren("WndClass", wndClass, 1, True)
For i = 0 To UBound(dlgs)
Set dlg = dlgs(i)
If aqObject.IsSupported(dlg, "WndCaption") Then
wndCaption = dlg.WndCaption
' use aqString.Compare for exact match or use aqString.Find
' if trying to identify object based on use of wildcards
If aqString.Find(wndCaption, caption, 0, False) <> 0 Then
If dlg.WaitProperty("Visible", True, delay) Then
msg = aqString.Format("The '%s' windows dialog is visible", wndCaption)
Log.Checkpoint msg,, pmNormal,, Sys.Desktop.ActiveWindow
FindChildDialog = True
End If
End If
End If
Next
End If
count = count + 1
Set parent = Nothing
Loop Until (FindChildDialog = True) Or (count < intMax)
End Function ' FindChildDialod