Board index » delphi » Automation object property which returns another automation object??

Automation object property which returns another automation object??

I'm trying to create an OLE automation interface to my application. I have a
main object called "_Application" which implements the "I_Application"
interface. I want to have a property called "CurrentUser" on this object
that returns an automation object of type "I_SystemUser".

My class that implements the _Application CoClass has an "FCurrentUser"
variable that is created in the "Initialize" method and destroyed in the
"Destroy" method. I then have a property "CurrentUser" that is declared as
"property CurrentUser: I_SystemUser" in the type library editor.

The implementation of the "Get_CurrentUser" function on the "T_Application"
class is as follows "Result := FCurrentUser".

For some reason, I can create an "_Application" OLE Automation object and
call _Application.CurrentUser.Method1, but when I try to call
_Application.CurrentUser.Method1 again, my _Application OLE automation
object gets destroyed and I get a "Catastrophic failure" message.

I can call other properties on the "_Application" OLE Automation object that
return strings or integers multiple times with no problems.

I'm using Delphi 3.01.

Anyone have experience with automation object properties that return other
automation objects? This is similar to Word 97 (i.e.
"Application.ActiveDocument.PrintOut", etc.) Thanks.

 

Re:Automation object property which returns another automation object??


I figured out my problem. I needed to call the "ObjAddRef" method on my
sub-object in the "Initialize" method of the main object.

Quote
Jeff Davis <jeff.da...@tamtron.com> wrote in message

news:7kc2mq$q4f10@forums.borland.com...
Quote

Other Threads