如何创建一个网页控件呢 除了用CWnd中的CreateControl(CLSID_WebBrowser,...不用MFC还能怎么创建呢??大虾帮帮忙请赐教,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #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(); 不用MFC还能怎么创建呢??====================楼主的意思是不用MFC哦只能用到基本的SDK了关注这个问题....帮你顶,等待高手 微软的Application Verifier到底是干什么的? 如何深入、系统的学习MFC编程? 高难度,请高手回答 如何取得一个窗口的句柄,并通过SendMessage函数向它发送一个wm_pain消息? 求学:先学vb好还是vc好 请问如何用GDI+实现两副图象的融合? 使用InternetConnect连接ftp,如何不使用默认的21端口而用别的自订端口 我想让CListCtrl控件,我想只能选择一行可不可以做到? 获取窗口句柄的奇怪问题!!!!!!!! 这个程序那个地方错了呢? 简单问题,多谢! 怎样才能做到按Enter键而不退出对话框???
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();
====================
楼主的意思是不用MFC哦
只能用到基本的SDK了
关注这个问题....
帮你顶,等待高手