Hi All
It appears I can only successfully remove an object if it is added via AddObject().
Unfortunately, the OLE appears to be less stable when I have the object defined via a PUBLIC variable. It will take some time to test with the AddObject() approach.
If someone could enlighten me as to:-
1) Why is there a difference between the two methods in respect to removing the object?2) Does creating with AddObject effect the way an object is bound?3) Is there anywhere I can find more infor on this?I would be most grateful.
Regards
Geoff Scott
>Hi
>
>I have a form which has OLE object in it. The form definition is contained in a non visual class as is the definition of the OLE object.
>
>
>PUBLIC oMain
>oMain = CREATEOBJECT('main')
>oMain.Show()
>READ EVENTS
>
>DEFINE CLASS main AS form
> Name = "Main"
> Desktop = .T.
> ShowWindow = 2
> DoCreate = .T.
>
> ADD OBJECT oTcpIp AS tcpip_server WITH ;
> Visible = .F.
>:
>:
>ENDDEFINE
>
>DEFINE CLASS TCPIP_Server AS olecontrol
> Name = "TCPIP_Server"
> OleClass = 'Server.MyServer'
>:
>:
>ENDDEFINE
>
>
>This works fine but priodically the OLE hangs and I need to be able to destroy the object and recreate it. (it's a little temperamental).
>
>When I issue an
>
>oMain.RemoveObject('oTcpIp')
>oMain.AddObject('oTcpIp', 'tcpip_server')
>
>
>I get an
Object Name is invalid error. The same happens when I use an empty container as my class. When I look in the debugger after the 'RemoveObject' I see that the object has not been destroyed (i.e. not removed).
>
>Using a public variable and releasing that is not really an option as the OLE needs to be bound to the form.
>
>Can someone explain why objects (even empty container objects) are not completely removed by the RemoveObject or what I am doing wrong and how I can fix it?
>
>Somewhat confused.
>Geoff Scott
May all your weeds be wildflowers