EnumObjectEmbeds Method
Object List Next Object
Defined By: ObjectTools
Description:
Enumerates embeds of an object.
Declaration:
Function EnumObjectEmbeds(ByVal host As Object, actor As Object, ByVal method As String) As Long
Details:
Host is the object whose embeds will be enumerated. For each object embedded in
host, the method specified by actor.method is invoked, with the embedded object as an argument. The actor’s method must take one object argument only, or an exception will be thrown.
Note that the method is specified by a string argument containing the name of
the method.
Either of the declarations below is acceptable for the actor’s method:
Sub EnumProc(o As Object)
Function EnumProc(o As Object) As Long
If the given method is a Sub, then it will be invoked for every object embedded in the host object, and
the return value of EnumObjectEmbeds will be zero.
If the given method is a Function..As Long, then the behavior and return value of EnumObjectEmbeds depends on the value
returned by the actor’s function. As long as that function returns zero, the enumeration continues.
If that function returns a non-zero value, the enumeration terminates
immediately, and that same non-zero value is returned from EnumObjectEmbeds.
The order in which embedded objects are visited by the enumeration is not
guaranteed.
Example:
To run the example below, copy the complete text from Type to End Type into a file with a .ETO extension. Then load that file into Phoenix as a text
module, and run the Example methods.
Type EnumEmbedsExampleObj
Dim foundObj As Object
Sub Example1
EnumObjectEmbeds(SamplesBrowser, Me, "PrintObject")
End Sub
Sub Example2
If EnumObjectEmbeds(SamplesBrowser, Me, "FindNonWin") Then
Debug.Print "Non-window:", foundObj
Else
Debug.Print "NO NON-WINDOWS FOUND."
End If
End Sub
Function FindNonWin(o As Object)
If TypeOf o Is Window Then
Debug.Print "Is-window:", o
FindNonWin = False
Else
foundObj = o
FindNonWin = True
End If
End Function
Sub PrintObject(o As Object)
Debug.Print o
End Sub
End Type
See Also:
EmbedObject, EnumObjectCopies, FindEmbed