Browser control Mozilla Activex control
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
Visual C++ ActiveX controls are slightly more tricky to use from C++, however here are 3 ways you can use the control. Subclassing CHtmlView MFC provides a CHtmlView class which may be used to instantiate the Internet Explorer control. Since the Mozilla control is API compatible, the steps are practically identical as using CHtmlView, except for overriding the Create method. a) Edit stdafx.h and add "#include <afxhtml.h>" to pull in the CHtmlView class. b) Derive your view class from CHtmlView and replace all calls to CView in your class to CHtmlView, e.g. in the IMPLEMENT_DYNCREATE macros and elsewhere. c) Override the default Create method of CHtmlView with your own: In the .h file add: public: virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); In the .cpp file add: BOOL CHtmlView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { // create the view window itself m_pCreateContext = pContext; if (!CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext)) { return FALSE; } AfxEnableControlContainer(); RECT rectClient; GetClientRect(&rectClient); const CLSID CLSID_MozillaBrowser = { 0x1339B54C, 0x3453, 0x11D2, { 0x93, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; // create the control window // AFX_IDW_PANE_FIRST is a safe but arbitrary ID if (!m_wndBrowser.CreateControl(CLSID_MozillaBrowser, lpszWindowName, WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDW_PANE_FIRST)) { DestroyWindow(); return FALSE; } LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp); if (!SUCCEEDED(hr)) { m_pBrowserApp = NULL; m_wndBrowser.DestroyWindow(); DestroyWindow(); return FALSE; } return TRUE; } Note that this code is practically identical to the code in the CHtmlView::Create method, the only change is that CLSID_MozillaBrowser is defined and supplied to the call to CreateControl instead of CLSID_WebBrowser (IE). d) In your view's OnInitialUpdate add a line such as this to see it working! Navigate2(_T("http://www.mozilla.org/"), 0, _T("")); Important Note: The CHtmlView::Navigate2 class calls IWebBrowser::Navigate with a target frame variant containing VT_BSTR and a NULL string value. Versions of the Mozilla control prior to Mozilla 1.3 did not like this and would crash, so specify the target as _T("") instead of NULL. Here is a sample application that uses CHtmlView. |
http://www.adamlock.com/mozilla/control.htm#usingC
http://www.adamlock.com/mozilla/control.htm#download
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=679
一条评论
Pingback: las ray ban mas baratas