Solved

Connection Application-ActiveX

Posted on 1998-07-08
6
275 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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