除了用CWnd中的CreateControl(CLSID_WebBrowser,...
不用MFC还能怎么创建呢??大虾帮帮忙请赐教,谢谢

解决方案 »

  1.   

    #define Assert(x) if(!x) MessageBox(NULL, "IE ERROR!", "Error", MB_ICONSTOP)    HRESULT                     hret;
        IUnknown                   *pUnknown;            
        IWebBrowser2               *pWebBrowser;
        IConnectionPoint           *pConnectionPoint;
        IConnectionPointContainer  *pConnectionPointContainer;
        IOleInPlaceObject          *pInPlaceObject;
        IOleObject                 *pObject;
        DWORD                       dwAdviseCookie;    // Initialize COM library
        OleInitialize(NULL);    // Setup member variables
        m_dwRefCount = 1;
        m_hwndParent = hwndParent;    // Instantiate all needed interfaces
        m_pClientSite = new ClientSite(this);
        m_pInPlaceSite = new InPlaceSite(this);
        m_pWebBrowserEvents2 = new WebBrowserEvents2(this);    // Instantiate Web Browser control
        hret = CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_ALL, IID_IUnknown, (void**)(&pUnknown));
        Assert(SUCCEEDED(hret));    // Set the client site
        hret = pUnknown->QueryInterface(IID_IOleObject, (void**)(&pObject));
        Assert(SUCCEEDED(hret));
        hret = pObject->SetClientSite(m_pClientSite);
        Assert(SUCCEEDED(hret));    // Set the site limits
        RECT rWindowPos;
        GetClientRect(hwndParent, &rWindowPos);
        
        rWindowPos.right -= rWindowPos.left;
        rWindowPos.bottom -= rWindowPos.top;
        rWindowPos.left = 0;
        rWindowPos.top = 0;
        
        hret = pUnknown->QueryInterface(IID_IOleInPlaceObject, (void**)(&pInPlaceObject));
        Assert(SUCCEEDED(hret));
        hret = pInPlaceObject->SetObjectRects(&rWindowPos, &rWindowPos);
        Assert(SUCCEEDED(hret));
        pInPlaceObject->Release();    // Activate the site
        hret = pObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_pClientSite, 0, hwndParent, &rWindowPos);
        Assert(SUCCEEDED(hret));
        pObject->Release();    // Set event handler
        hret = pUnknown->QueryInterface(IID_IConnectionPointContainer, (void**)(&pConnectionPointContainer));
        Assert(SUCCEEDED(hret));
        hret = pConnectionPointContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &pConnectionPoint);
        Assert(SUCCEEDED(hret));
        hret = pConnectionPoint->Advise(m_pWebBrowserEvents2, &dwAdviseCookie);
        Assert(SUCCEEDED(hret));
        pConnectionPointContainer->Release();
        pConnectionPoint->Release();    // Get Web Browser interface
        hret = pUnknown->QueryInterface(IID_IWebBrowser2, (void**)&pWebBrowser);
        Assert(SUCCEEDED(hret));
        if(pUnknown) pUnknown->Release();    // Go to URL
        hret = pWebBrowser->Navigate(L"http://www.google.com", NULL, NULL, NULL, NULL);
        Assert(SUCCEEDED(hret));
        if(pWebBrowser) pWebBrowser->Release();
      

  2.   

    不用MFC还能怎么创建呢??
    ====================
    楼主的意思是不用MFC哦
    只能用到基本的SDK了
    关注这个问题....
    帮你顶,等待高手