sending classes through interfaces 
Author Message
 sending classes through interfaces

my situation is this...

i would like to create a class CXyz

then I would like to create a simple ATL Object that could
contain a method such as SetXYZValue(CXyz xyz)

so if my object was  CObjX* pxyz, i could make the call

pxyz->SetXYZValue(xyz)

is this possible?
are you just limited to the types listed in the interface
data types list?

thanks, in advance

Michael



Sun, 22 Feb 2004 03:45:33 GMT  
 sending classes through interfaces
Michael,

Does the class that you want to pass to the ATL object have an interface
defined in the IDL file ?  That is, is there a IXyz ?  If there is, you can
pass that in without a hitch...  Otherwise, I think that you will get an
error when you compile your ATL object's IDL file with MIDL, because the
class CXyz is unknown to the compiler.  I suggest that you either make IXyz
or you pass a void pointer to the ATL object through the use of a variant
and then cast it to your appropriate type in the implementation of the ATL
object.

Regards,

Mark Janveaux


Quote:
> my situation is this...

> i would like to create a class CXyz

> then I would like to create a simple ATL Object that could
> contain a method such as SetXYZValue(CXyz xyz)

> so if my object was  CObjX* pxyz, i could make the call

> pxyz->SetXYZValue(xyz)

> is this possible?
> are you just limited to the types listed in the interface
> data types list?

> thanks, in advance

> Michael



Sun, 22 Feb 2004 04:55:51 GMT  
 sending classes through interfaces
As far as I know, there is no easy way to pass a C++ class into an ATL COM
Object. (Maybe if you wrote a custom marshaller, you could marshal one in,
and re-hydrate it there).

If you are passing an a variety of unknown ATL objects, passing in the
IUnknown pointer of the incoming object and Querying for supported
interfaces in the receiving COM object would be the easiest way to go.

Good luck,
Dave White
http://www.slb.com


Quote:
> my situation is this...

> i would like to create a class CXyz

> then I would like to create a simple ATL Object that could
> contain a method such as SetXYZValue(CXyz xyz)

> so if my object was  CObjX* pxyz, i could make the call

> pxyz->SetXYZValue(xyz)

> is this possible?
> are you just limited to the types listed in the interface
> data types list?

> thanks, in advance

> Michael



Sun, 22 Feb 2004 09:05:42 GMT  
 sending classes through interfaces
This is against the basic COM rule - COM is language independent.
You cannot pass language specific data (a C++ class instance).
Shortly - this is imposible to do in COM. If you use one of the
hacks mentioned in the other replies, you step outside COM
and nothing provided by COM is guaranteed for you. It's like
being an outlaw...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> my situation is this...

> i would like to create a class CXyz

> then I would like to create a simple ATL Object that could
> contain a method such as SetXYZValue(CXyz xyz)

> so if my object was  CObjX* pxyz, i could make the call

> pxyz->SetXYZValue(xyz)

> is this possible?
> are you just limited to the types listed in the interface
> data types list?

> thanks, in advance

> Michael



Mon, 23 Feb 2004 01:49:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. using non dll-interface class as base for dll-interface class

2. class class-name: base-class : interface

3. Internal Compiler Error while deriving C# class from a MC++ class implementing a C# interface

4. Howto Expose a normal C++ class with methods via an Interface Class in ATL COM

5. Sending messages to ActiveX user interface controls from a different thread

6. Calling a class member's interface method from a non interface method on the parent class

7. Warning C4251: Using non-dll-interface classes in dll-interface classes.

8. how to send data by CSocket Class?

9. Want to send events from the class

10. send mail classes

11. Send Class-Object via Socket-Connection?

12. Sending and receiving files trought CAsyncSocket derived class

 

 
Powered by phpBB® Forum Software