Solved

Connection Application-ActiveX

Posted on 1998-07-08
6
277 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SAPE.heur.AE935 Visual Studio 3 74
windbg taking it's time 32 108
Licensing Sharepoint 2016 for developers 11 100
Visual Studio Start / Browser Emulator menu different 2 40
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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 video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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