Link to home
Start Free TrialLog in
Avatar of Hugi
Hugi

asked on

Connection Application-ActiveX

I tried to send an event from my Application to an ActiveX as follow, but the event newer touched my ActiveX - where can be the mistake?

void CSourceDoc::FireEventV(DISPID dispid, BYTE* pbParams,
      va_list argList)
{
      COleDispatchDriver driver;
      const CPtrArray* pConnections = m_xEventConnPt.GetConnections();
      ASSERT(pConnections != NULL);

      int i;
      int cConnections = pConnections->GetSize();
      LPDISPATCH pDispatch;
      for (i = 0; i < cConnections; i++)
      {
            pDispatch = (LPDISPATCH)(pConnections->GetAt(i));
            ASSERT(pDispatch != NULL);
            driver.AttachDispatch(pDispatch, FALSE);
            TRY
                  driver.InvokeHelperV(dispid, DISPATCH_METHOD, VT_EMPTY, NULL,pbParams, argList);
            END_TRY
            driver.DetachDispatch();
      }
}
Avatar of galkin
galkin

Event is fired by the control to container, not vice versa. If you want to access control's property or method from container you can quere for an interface and then call its method.
Avatar of Hugi

ASKER

But I need access to the same instance of the interface and when I quere for an interface I get a new instance.
I guess you're confused. When you create control with CoCreateInstance you get reference to IUnknown or ther interface you quere. OLe polymorphism states that you can quere any interface from any interface and get the same result. So you can quere the interface you are interested in and call its methods.
Avatar of Hugi

ASKER

This might be OK when I just need a method, but when I want to connect to an other process, it doesn't works.
ASKER CERTIFIED SOLUTION
Avatar of ERGO
ERGO

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to call a method of custom interface of out of process server you need to implement marshaling to marshal call across process boundaries. If you call standard OLE inteface method i.e. IDispatch::Invoke, OLE already provides marshaling so you don't need to care.