Click here to Skip to main content
13,090,519 members (58,316 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm playing around with implementing a web browser based on the Internet Explorer Web Browser control. I've created an MFC project and created a wrapper class for the control, so that class now has Create() methods and a bunch of methods that call InvokeHelper(). In and of itself, that all works; I can run the project and I do indeed get a nicely-functioning web browser in my view.

Now I would like to start tapping into the advanced functionality of the control - for example, adding an event sink for DWebBrowserEvents2. Unfortunately this is where I have hit a brick wall, as I don't seem to have a way of doing anything COM-like, such as QueryInterface() or whatever is required for the event sink from that wrapper class.

The article here:

talks about using a smart pointer to start implementing the sink (e.g.: m_spIEventFiringObject.CreateInstance(__uuidof(EventFiringObject)); ), but the wrapper class doesn't seem to expose anything IID / uuid-related to do that.

I had a look at COleControlSite, which I can get from the class, but that didn't give too many clues.

The code for my wrapper class starts with this sort of thing:

class CWebBrowser : public CWnd
    CLSID const& GetClsid()
        static CLSID const clsid
            = { 0x8856F961, 0x340A, 0x11D0, { 0xA9, 0x6B, 0x0, 0xC0, 0x4F, 0xD7, 0x5, 0xA2 } };
        return clsid;
    virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
                        const RECT& rect, CWnd* pParentWnd, UINT nID, 
                        CCreateContext* pContext = NULL)
        return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); 
    BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, 
                UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
                BSTR bstrLicKey = NULL)
        return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
        pPersist, bStorage, bstrLicKey); 
// Attributes
// Operations
// IWebBrowser2
// Functions
    void GoBack()
        InvokeHelper(0x64, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    void GoForward()
        InvokeHelper(0x65, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

Can anyone help guide me as to how to proceed?

Posted 25-Nov-12 0:43am
Mahdi Nejadsahebi 5-Apr-13 10:58am
if you need to use web browser as skin mode, add "web browser" from com components to your project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100