Solved

Connection Application-ActiveX

Posted on 1998-07-08
6
278 Views
Last Modified: 2013-12-04
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();
      }
}
0
Comment
Question by:Hugi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1409635
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.
0
 

Author Comment

by:Hugi
ID: 1409636
But I need access to the same instance of the interface and when I quere for an interface I get a new instance.
0
 
LVL 7

Expert Comment

by:galkin
ID: 1409637
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.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:Hugi
ID: 1409638
This might be OK when I just need a method, but when I want to connect to an other process, it doesn't works.
0
 

Accepted Solution

by:
ERGO earned 50 total points
ID: 1409639
Your code seems correct, check if you did the connection in your ActiveX
0
 
LVL 7

Expert Comment

by:galkin
ID: 1409640
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.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question