Virtual Developer Workshop: Containerized Development with Docker

Environment: VC6 SP4, ie5, ie5-lib

This example demonstrates how to access DHTML object model and how to intercept the DHTML element events, it also demonstrates how to use connectionpoint with MFC. The demo program first loads up a sample html page containing two button elements and a listbox element. Then it accesses a button element DHTML object and intercepts its Click, DoubleClick, MouseMove, MouseOver, MouseDown, MouseUp events. After the program intercepts an event, it records the event information to a ListBox element on sample html page. The example is showing that MSHTML is very useful for internet and web programming. I hope this example provides some help for any one who want to use MSHTML library. (You need to download ie5_lib or a later IE library to compile the demo project)


Download demo project - 48 Kb


  • Problem setting connection point on Input Image type elements.

    Posted by kamleshsoni1979 on 11/25/2004 05:49pm

      I modified the mshtmlhook demo code a bit to also add one more element in the html page loaded by the dialog. The element is Input image type. And the code added to the html page is .
    I modified the code for CMshtmlhookDlg and added one more api for setting connection points on this Input Image element.
    void CMshtmlhookDlg::ConnectImage(IHTMLInputImage* pImageElem)
    	HRESULT hr = 0;
    	IConnectionPointContainer* pCPC = NULL;
    	IConnectionPoint* pCP = NULL;
    	IUnknown* pUnk = NULL;
    	DWORD dwCookie;
           // Check that this is a connectable object.
    	hr = pImageElem->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
        if (hr == S_OK)
    		// Find the connection point.
    	hr = pCPC->FindConnectionPoint(DIID_HTMLInputImageEvents, &pCP);
    		if (hr == S_OK)
    			//AfxMessageBox("Find connection point ");
    			// Advise the connection point.
    	    // pUnk is the IUnknown interface pointer for your event sink
    			CDHTMLEventSink* pSink = new CDHTMLEventSink;
    			IUnknown* pUnk = pSink->GetInterface(&IID_IUnknown);
    			hr = pCP->Advise(pUnk, &dwCookie);
    		if(pCP == NULL)
    			AfxMessageBox("Find connection point input image elment failed");
    But FindConnectionPoint(DIID_HTMLInputImageEvents, &pCP) api used above fails to find the connection point on Input Image Element. Can any one suggest any reason for this failure or is there any workaround for this. The connection points gets set properly for all the other kinds of html elements but for Input Image type. Please help.
    Thanks and Regards,

  • Great implementation of event sink!

    Posted by piotrmb on 06/14/2004 01:37pm

    Simple, yet functional implementation of event sink! Great job.

  • how can i get the click event on IHTMLInputButtonElement

    Posted by Legacy on 08/28/2003 07:00am

    Originally posted by: east zhang

    My dear friend:
    This program is very helpful for me. I can get the click event on my IHTMLInputButtonElement and Now I want to get the IHTMLInputButtonElement via IHTMLEventObj too,I tried many times,but all failed.Can anyone help me? Thank you for advance!

    • ok

      Posted by journeyMFC on 10/17/2008 06:03pm

      very good!

  • Clicking formatted links: how can I get anchor value?

    Posted by Legacy on 07/22/2003 07:00am

    Originally posted by: Vladimir Kamsky

    Situation: <A HREF=url><B>Some link</B></A>

    I'd like to intercept anchor clicking.
    When clicking at this link I've got "clicking bold text" (most internal). How can I get outer <A HREF=url>?

  • MSHTMLHOOK in netscape also?

    Posted by Legacy on 06/22/2003 07:00am

    Originally posted by: Jayaprabha

    Can MSHTMLHOOK be used to access the document of netscape also?

  • why don't work "VTS_DISPATCH" option in "DISP_FUNCTION_ID" macro

    Posted by Legacy on 04/17/2003 07:00am

    Originally posted by: Jin4309

    hi~ i'm a beginning Programmer....download this sample ago 3 weeks....

    but, can't compile....i readed yours reply Message, and find measures....that say modify code can compile....that is right...

    But....Modify Code have a big trouble....DISP_FUNCTION_ID macro option(6th) is VTS_NONE....it is no argument function's option....but i need EventObj...

    but change VTS_NONE to VTS_DISPATCH(or other opton) function haven't Run Time

    Why? plz help me....

  • Don't work

    Posted by Legacy on 03/12/2003 08:00am

    Originally posted by: hongwei

    I download this example and compiled it. after run ,sink evnet don't work,why?

    win2000 + vc6 sp5 + ie5.0

    • use ie6,it can work

      Posted by xqyz8888 on 04/12/2004 08:36am

      i do not know the reason

  • OK but capture mouse click for all the web page ?

    Posted by Legacy on 01/31/2003 08:00am

    Originally posted by: jeremyS

    with this example i understand to capture mouse click on buttons, but i want detect mouse click down et mouse click up for all web page.
    when someone selct text in the html document i want to know the mouse position when clisk down and the position when click up !
    you know how to do this??

  • Can you embed a contol in an HTML page that can do this?

    Posted by Legacy on 12/05/2002 08:00am

    Originally posted by: Joseph Mueller

    I noticed that the code you have works by having an application (exe) open a browser.  Is it possible for an ActiveX control to do the same thing if it is embeded in an HTML page?  When I have tried doing this I get a memory access violation.  If this is possible, how do you do this?  I have been trying to do this for weeks now and I can't get anywhere.


  • What does the mshtmlhook.odl do?

    Posted by Legacy on 10/22/2002 07:00am

    Originally posted by: nodman

    Hello everyone, I just downloaded the hook example and found it is pretty good! I have it modified and merge it into my project, much thanks to author!

    I found there is a "mshtmlhook.odl" file in the example. I dont know what it is, I removed it from project and it works properly anyway, what I want to know about is what can this ODL file do? Will I meet some trouble in the future without the ODL file?

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date