Chapter Summary

 < Free Open Study > 



COM objects like to mingle with each other. Many times, a client will make requests of a coclass and require no further interaction. However, when you wish to allow your coclass to "talk back" to the client you have two basic approaches. First off, you can create a custom callback interface which is defined by the coclass and implemented by the client. Through the use of custom methods, a client may set up an advisory connection to the object, passing in a reference to the client-side sink. The only downfall to this strategy is that callback interfaces do not allow for a common standard.

COM provides a standard for bidirectional communications named connectable objects. Using IConnectionPointContainer, a client may discover the types of connection points held in the container. IConnectionPoint allows the client to Advise() and Unadvise() for a given connection. Building a connectable object by hand can be quite a chore, given that the object must maintain a list of each client currently connected to each connection point.

Luckily, ATL provides the Implement Connection Point Wizard, which automatically builds a connection point proxy based off your IDL code. The generated connectable object leverages code from IConnectionPointImpl<>, which maintains the list of connected clients and assigns numerical cookies to each.



 < Free Open Study > 



Developer's Workshop to COM and ATL 3.0
Developers Workshop to COM and ATL 3.0
ISBN: 1556227043
EAN: 2147483647
Year: 2000
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net