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

  • SEARCH
  • Home
  • 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 8559051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:57:00+00:00 2026-06-11T15:57:00+00:00

I have a Windows native C++/Win32/MFC dialog app. I’m using the IE ActiveX control

  • 0

I have a Windows native C++/Win32/MFC dialog app. I’m using the IE ActiveX control in the dialog to render some HTML content. The HTML being rendered contains a button. The button has an onClick javascript handler as shown below.

<input type="button" id="uniqueButtonID" name="uniqueButtonName" value="blue" onClick="OnButtonClick('blue');">

Currently the button click is handled in the page by the javascript handler shown. This all works.

I’d like to, instead, handle the button click in the dialog C++ code.

I have some experience handling other events in the dialog. For example, the below works and allows handling the doc complete event and navigation.

BEGIN_EVENTSINK_MAP(DMyDlg, CDialog)
ON_EVENT(DMyDlg, IDC_EXPLORER2, 259, DMyDlg::DocumentCompleteExplorer2, VTS_DISPATCH VTS_PVARIANT)
ON_EVENT(DMyDlg, IDC_EXPLORER2, 250, DMyDlg::BeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()

These are pre-defined well known events though. Not sure how to translate that into handling something I’ve defined in the button in the onClick=”” section.

Anyone know how to do this? The motivation here is that I have some code used in another C++ app which defines some business logic. I want the same business logic used here. Currently I have to translate that into Javascript every time. If I could handle the event in the C++ code I could just copy/paste (or re-use through a DLL) and avoid the Javascript translation stage.

  • 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-06-11T15:57:01+00:00Added an answer on June 11, 2026 at 3:57 pm

    You will need to create a COM object as the bridge between JavaScript and C++. The JavaScript initialization code will look something like:

    var myhelper = new ActiveXObject("MyCompany.MyHelper");
    

    Note that despite the name “ActiveXObject”, the object does not have to be a full ActiveX control, just a COM object. Then in your onClick handler you can just do:

    myhelper.DoThis();
    myhelper.DoThat();
    

    The “fun” part is creating the COM object in C++ – IDL files, ATL classes, IDispatch, IUnknown and all that stuff I am trying to forget.

    One thing though – if the C++ code exists in your application exe (not in a separate COM DLL), don’t forget that when your program starts up, you must create a class factory instance for “MyCompany.MyHelper” and register it with COM so that the “new ActiveXObject” in JavaScript succeeds.

    [update 1]

    I should have added in my initial response – I don’t actually recommend doing this if you can avoid it. Back before C# and .NET existed, we in our company actually though COM was a good thing and it was worth the time and effort to learn it. Today … not so much.

    In your case, having your business logic in C++ and again in JavaScript might seem like a lot of extra work – but at least it is extra work that you can plan, allocate resources to and have a hope of being able to finish. Once you go down the path of C++/COM/ActiveScripting, when stuff stops working – there is no limit to the amount of time you might spend trying to chase down obscure COM related issues. Anyhow good luck!

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

Sidebar

Related Questions

I'm working on a native C++/Win32/MFC app on Windows 7. I'm using CFile to
Windows resources have a FileVersion and a ProductVersion. In native development environment(eg. Win32 app,
I have a need to do some drawing using win32/GDI (Native, not .NET), and
Some Windows native applications have a question mark icon on the title bar. It's
We have a native C++ Win32 .exe built using Visual Studio 2005 that works
I have a .NET application that makes calls to a native Win32 DLL using
We have Win Forms application uses the 3rd party windows native controls. Can these
I read that Windows wp8 allows native code. So how then have ports such
My weird monitor's native resolution isn't recognized by Windows, so I have to set
Windows 7 and Windows Vista have a Region and Language control panel which contains

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.