Search code examples
winapicommshtml

What is the different between HTMLDocumentEvents and HTMLDocumentEvents2?


What is the different between HTMLDocumentEvents and HTMLDocumentEvents2 of mshtml ?


Solution

  • These are different interfaces: different methods, even though some are duplicating one another exactly or extending.

    HTMLDocument COM object is capable to deliver events using several interfaces and it is up to COM client to choose which interface to use. Originally it was HTMLDocumentEvents and then a need to extend the object adding new events suggested to leave the original interface intact and add new event interfaces with new methods (HTMLDocumentEvents2, HTMLDocumentEvents3, HTMLDocumentEvents4).

    Extended interface can have additional methods, arguments without danger of breaking compatibility with existing clients using older event interface, e.g. onhelp, onclick methods on the two interrfaces:

    dispinterface HTMLDocumentEvents {
        properties:
        methods:
            [id(0x8001000a)]
            VARIANT_BOOL onhelp();
            [id(0xfffffda8)]
            VARIANT_BOOL onclick();
    
    dispinterface HTMLDocumentEvents2 {
        properties:
        methods:
            [id(0x8001000a)]
            VARIANT_BOOL onhelp([in] IHTMLEventObj* pEvtObj);
            [id(0xfffffda8)]
            VARIANT_BOOL onclick([in] IHTMLEventObj* pEvtObj);