Derek,
No, an object can not be instantiated by one object and then added to another form. An object can not have 2 parent objects. In order for an object to participate in the UI event loop, it must be created using AddObject().
You could kind of work this with a callback mechanism:
do form myForm with this, "CustomizeIt"
roForm.AddObject( "myContainer" )
with roForm.myContainer
.Visible = .t.
endwith
return
lparameter roCaller, pcCallback
evaluate( "roCaller." + pcCallBack + "( thisform )" )
But I think you are going to have a bit of a problem getting the data back from those controls the client code is adding in, it would take another callback.
You might want to create a specialized container class that can deal with these connection issues. The client code can simply pass in the name of the class that it wants added to myForm.
>Hello. I have a generic dialog that I would like to be able to pass a more customized Container object into for any custom controls the client code requires(a certain area of the form is dedicated for this). The container object is created by the client code, as it may want to customize the properties at run-time based on the current context. Is there any way to add an instantiated object to the form when I run it? AddObject() and NewObject() both create objects from a class, so they won't work...
>
>Something like this:
>
>CLIENT CODE:
>
>LOCAL oCustomContainer
>oCustomContainer = CREATEOBJECT("custom.container")
>oCustomContainer.txtTextbox.Value = "my custom text"
>
>DO FORM myForm with oCustomContainer
>
>
>Form's Init event:
>
>LPARAMETERS toContainer
>
>This.AddInstantiatedObject("FormName", toContainer)
>
>
>I'll probably end up just having to not let the client code customize the container before it's run(have it pass in a classname instead of an object), but I'm seeking the community's wisdom before giving up. Thanks.