15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Communication between two OCX using OLE Automation

Sridhar Rao Chedalla -- C.Sridhar@blr.sni.de
Sunday, December 22, 1996

Hello,

        Environment : VC++ 4.0, NT 3.51

        Is there any other method of better communication between two
OCX's
other than OLE automation. The problem is I want to implement an OCX to
which any other OCX controls can communicate. For this I have exposed
some methods in my OCX control and also  I have generated typelibrary
file(.tlb) and a class derived from COleDispatchDriver.

        Now any body who wants to communicate with me has to get by
COleDispatchDriver derived class contact my OCX control througgh progID
or clsID supplied by me. And if I want to call them back I do not have
their details. So I have put progID as the first parameter for all my
exposed methods so that I can know the other OCX information through
which I can contact them.

        Is there any other better solution than this. 

        One more problem is if I want to pass variable length
information (exa.
a list in which  no. of items may differ) can I pass one of the
parameter of exposed methods as IUnknown and send the data through
IDataObject and again type cast it from IUnknown to IDataObject. Is this
a better solution or is there any other way we can send varitable length
data. Does any body have such samples.

C.Sridhar

SIEMENS INFORMATION SYSTEMS LTD.
csridhar@blr.sni.de



Mike Blaszczak -- mikeblas@nwlink.com
Sunday, December 22, 1996

At 12:03 12/22/96 +0530, Sridhar Rao Chedalla wrote:

>        Now any body who wants to communicate with me has to get by
>COleDispatchDriver derived class contact my OCX control througgh progID
>or clsID supplied by me. And if I want to call them back I do not have
>their details. So I have put progID as the first parameter for all my
>exposed methods so that I can know the other OCX information through
>which I can contact them.
>
>        Is there any other better solution than this. 

Connection Points provide a mechanism for providing callbacks in this
manner.  The real trick is to design a custom interface that the source
and the sink both know about so that the source doesn't have to know
anything specific about the sink --other than the fact it implements
the sink interface.

Connection Points are discussed in the MFC docs, since they're used
in the implementation of OLE Controls.  ATL provides some cool templates
for writing both sources and sinks (and dealing with multicasting and
solving some other issues).  The MSDN Developer Library CD has some
articles about the use of connection points in the design of your
object model.

.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |