FoxPro Programming
Passing Objects between COM-Server
Gravatar is a globally recognized avatar based on your email address. Passing Objects between COM-Server
  Toni Köhler
  All
  Jun 26, 2024 @ 12:48am

Hi Folks,

do you know a way to pass objects between VFP and a VFP based COM-Server in this way that the properties of the objects are visible? If I receive the object from COM-Server as RETURN-Value I see in the debugger that it is a object, but I can't see the properties.

So I can't use with PEMSTATUS(), I must use with TYPE("..."). But this only works, if I know the structure of the object.

Regards Toni

Gravatar is a globally recognized avatar based on your email address. re: Passing Objects between COM-Server
  Rick Strahl
  Toni Köhler
  Jun 26, 2024 @ 08:52am

It's not possible. COM Objects are not FoxPro objects so the normal mechanism for parsing type information is not available. The only way to get type information on COM objects is via the type library which has to be parsed. You can get debug information for Intellisense via LOCAL declarations but that only works at development time in the IDE, not at runtime.

At compile time in the FoxPro IDE you can declare your types explicitly and you will get IntelliSense assuming that a type library is available for that COM object (not all of them have one).

For Intellisense you can do this:

LOCAL loBrowser as InternetExplorer.Application
loBrowser = CREATEOBJECT("InternetExplorer.Application")
loBrowser.   && <-- you'll get Intellisense

and you will get Intellisense for the properties if stepping through the code.

But even that is very limited as it usually breaks if you step one or more levels down in the object hierarchy. Reason being that most COM objects don't write out complete type libraries - for example, if you compile a FoxPro object to COM only the top level class goes into the type library. If you have child classes they have to be explicitly declared as COM objects.

But there is no runtime mechanism for this. The reason for this is that COM has no mechanism for actually iterating available functionality in IDispatch and IUnknown - the way you find out if something exists at runtime is by actually trying to get a pointer to the function. IOW you have to know what you're looking for in the first place.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Passing Objects between COM-Server
  Toni Köhler
  Rick Strahl
  Jun 26, 2024 @ 07:40pm

Thank you for the explantation.

*** Toni /// 😉

© 1996-2024