Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ COM Browser
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:
 
http://www.codeproject.com/Articles/9014/Understanding-COM-Event-Handling
 
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
{
protected:
    DECLARE_DYNCREATE(CWebBrowser)
public:
    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
public:
enum
...
 
// Operations
public:
 
// 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?
 
Thanks.
Posted 25-Nov-12 0:43am
Comments
Mahdi Nejadsahebi at 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
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 176
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 156
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2014
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