Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1023793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:40:51+00:00 2026-05-16T11:40:51+00:00

I have an ATL ActiveX control that raises three events (Connected, Authenticated, Disconnected) which

  • 0

I have an ATL ActiveX control that raises three events (Connected, Authenticated, Disconnected) which need to be handled in IE/JavaScript. So far as I can tell, I’m doing everything right, specifically:

(1) I’ve told ATL to implement the IProviderClassInfo2 interface, as described here.

(2) I’ve implemented connection points within my ATL project by following the directions here. I now have a CProxy_IMyControlEvents class, with the appropriate Fire_Authenticated(), Fire_Connected() and Fire_Disconnected() implementations. They look more-or-less like this:

template<class T>
class CProxy_IVncServerControlEvents :
 public ATL::IConnectionPointImpl<T, &__uuidof(_IVncServerControlEvents)>
{
public:
HRESULT Fire_Connected()
 {
  HRESULT hr = S_OK;
  T * pThis = static_cast<T *>(this);
  int cConnections = m_vec.GetSize();

  for (int iConnection = 0; iConnection < cConnections; iConnection++)
  {
   pThis->Lock();
   CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
   pThis->Unlock();

   IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);

   if (pConnection)
   {
    CComVariant varResult;

    DISPPARAMS params = { NULL, NULL, 0, 0 };
    hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,  &params, &varResult, NULL, NULL);
   }
  }
  return hr;
 }
};

(3) I’m calling Fire_Connected() et al at the appropriate points in my code (on the main UI thread), and the debugger confirms that they’re firing.

(4) I’m instantiating the resulting control in an HTML page, and am able to call methods on it. These methods do what they’re supposed to do and return successfully.

<object id="MyControl" classid="CLSID:42832F4C-3480-4450-A6B5-156B2EFC408F" codebase="http://localhost:51150/Resources/MyControlInstaller.CAB" />

<script language="javascript">
var myControl = document.getElementById("MyControl");
myControl.connect();
</script>

(5) I’m wiring up the events to JavaScript function handlers. This seems to be where I’m running into trouble. I’ve seen three different ways of doing it referenced, and none of them seem to be working for me.

<!-- Method #1 -->
<script language="javascript">
myControl.attachEvent('Connected', onConnected);
myControl.attachEvent('Disconnected', onDisconnected);
myControl.attachEvent('Authenticated', onAuthenticated);
</script>

<!-- Method #2 -->
<script language="javascript">
myControl.Connected = onConnected;
myControl.Disconnected = onDisconnected;
myControl.Authenticated = onAuthenticated;
</script>

<!-- Method #3 -->
<script for="MyControl" language="javascript">
function MyControl::Connected()
{
    onConnected();
}

function MyControl::Disconnected()
{
    onDisconnected();
}

function MyControl::Authenticated()
{
    onAuthenticated();
}
</script>

I’ve ready up on everything I can find on the Internet about how to do this, and it doesn’t seem like I’m leaving anything out. So I must be doing something stupid. Any suggestions about what I might be doing wrong or how to troubleshoot it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:40:52+00:00Added an answer on May 16, 2026 at 11:40 am

    I figured it out by looking at the Circ sample project that comes with VS2010. Turns out that (at least in my case) the ATL event wizard didn’t update the IDL for the dispatch interface. Life was good once I updated the dispinterface section of the IDL file from this:

    dispinterface _IMyControlEvents
    {
        properties:
        methods:
    };
    

    To this:

    dispinterface _IMyControlEvents
    {
        properties:
        methods:
            [id(1)] void Connected();
            [id(2)] void Disconnected();
            [id(3)] void Authenticated();
    };
    

    Once I did that, I was able to get the various different event handling syntaxes to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ActiveX control written using the MS ATL library and I am
I have an ATL control that I want to be Unicode-aware. I added a
We have a COM object implemented with C++/ATL that includes a method which will
I have an ActiveX control that works fine in Internet Explorer and the ActiveX
I have an ActiveX control written in C++ that I created with VS2008 and
I've written an ActiveX control using ATL. I used the wizard to add support
I've written an ATL/ActiveX object which exposes various properties and methods through its COM
Have created a ATL COM project through which I am inserting Menu Items to
i have a input tag which is non editable, but some times i need
I have a COM component, implemented in C++ with ATL, that uses overlapped socket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.