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 7059373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:13:28+00:00 2026-05-28T04:13:28+00:00

I have a html-page loaded in a CDialog in an MFC application, using the

  • 0

I have a html-page loaded in a CDialog in an MFC application, using the IE8 engine, and an instance of CDHtmlDialog. The html-page contains <input> elements, and includes jQuery. In said jQuery, I have this code:

$(function()
{$
  $('#Left').change(function()
  {
     $('[id$=left]').prop('disabled', ! $(this).is(':checked') );
  }).change();
});

Which essentially just keeps some inputs and selects (chosen by id convention) disabled or enabled, based on the checkbox with the id #Left.

The issue being: When I change the checkbox from the C++ code like so:

// Get pElements checkbox through doc->getElementsByTagName("input")
CComQIPtr<IHTMLInputElement> spInputElement(pElement);
spInputElement->put_checked(true);

then the change event does not fire (possibly to avoid infinite recursion), and the other inputs never update. Is there a way in which I can fire the change-event explicitly from my C++? I would prefer not to require all checkboxes to have specific html-code (such as an explicit onchange=”…”), as that would be impractical for maintenance.

  • 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-28T04:13:28+00:00Added an answer on May 28, 2026 at 4:13 am

    So, thanks to amadeus, I got it figured out. This is the code that works, so everyone else can just copy-paste it if they need it.

    void fireOnChangeEvent(IHTMLElement* pElement)
    {
        // Create a new event-object
        IHTMLEventObj* eventObject;
        IDispatch* dispatch;
        pElement->get_document(&dispatch);
        CComQIPtr<IHTMLDocument4, &__uuidof(IHTMLDocument4)> doc = dispatch;
        dispatch->Release();
        VARIANT empty;
        VariantInit(&empty);
        doc->createEventObject(&empty, &eventObject);
    
        // fire event
        VARIANT eventref;
        VariantInit(&eventref);
        V_VT(&eventref) = VT_DISPATCH;
        V_DISPATCH(&eventref) = eventObject;
    
        VARIANT_BOOL cancellable;
    
        CComQIPtr<IHTMLElement3, &__uuidof(IHTMLElement3)> element3 = pElement;
        BSTR bstrChange = SysAllocString(L"onchange");
        element3->fireEvent(bstrChange, &eventref, &cancellable);
        SysFreeString(bstrChange);
    }
    

    Note that this will not fire any events described in JQuery, but it will get all those that are declared directly in the html as onchange="..."

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

Sidebar

Related Questions

I have an html page loaded into a PHP variable and am using str_replace
I have a html page displayed using... cherrypy.quickstart(ShowHTML(htmlfile), config=configfile) Once the page is loaded
I have an HTML page (say welcome.html) which contains an iframe to a page
We have an HTML page which displays a bunch of pretty bars using divs
I have an HTML page (it's out of an internal address book application) and
I have a html page which loads a flash(flex) swf file. Using https it
I have a 2-frame HTML page: FrameA contains a list of links to various
I have a simple html page with a div. I am using jQuery to
Is it possible? I mean, I have loaded html page (with HtmlAgilityPack for example)
I have a html page, with jquery loaded. It has no css at the

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.