From d552eeb0376349c71ed04e2c3dba32a47b8e146e Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 18 Oct 2024 16:02:36 +0100 Subject: [PATCH] IDE-1137 Remove IE based embedded browser Removed some additional unused files Signed-off-by: Gordon Smith --- eclide/HistoryDlg.cpp | 310 -------------------------------- eclide/HistoryDlg.h | 10 -- wlib/HtmlIEView.cpp | 401 ------------------------------------------ 3 files changed, 721 deletions(-) delete mode 100644 eclide/HistoryDlg.cpp delete mode 100644 eclide/HistoryDlg.h delete mode 100644 wlib/HtmlIEView.cpp diff --git a/eclide/HistoryDlg.cpp b/eclide/HistoryDlg.cpp deleted file mode 100644 index 20c182d4..00000000 --- a/eclide/HistoryDlg.cpp +++ /dev/null @@ -1,310 +0,0 @@ -#include "stdafx.h" -#include "resource.h" - -#include "historydlg.h" -#include "attribute.h" -#include "eclview.h" -#include "vdiff.h" - -class CCompareDlg : public CDialogImpl, - public CDialogResize, - public CWinDataExchange -{ - typedef CCompareDlg thisClass; - typedef CDialogImpl baseClass; - typedef CDialogResize baseClassResize; - typedef CDialogResize baseClassDDX; - -protected: - CListViewCtrl m_HistoryList; - CAxWindow m_wndIE; - CComQIPtr m_pWB2; - CEclView m_ecl; - CAtlTemporaryFile m_DiffPath; - CAtlTemporaryFile m_LeftPath; - CAtlTemporaryFile m_RightPath; - CComPtr m_Attribute; - IAttributeHistoryVector m_History; - int m_HistorySel; - int m_SelCount; - int m_Sel1; - int m_Sel2; - bool m_InitSingleSelect; - -public: - CCompareDlg(IAttributeHistory * current, IAttribute * attribute, bool selectSingle) : m_Attribute(attribute), m_InitSingleSelect(selectSingle) - { - if (current) - m_History.push_back(current); - CCompareDlgConstruct(); - } - - CCompareDlg(IAttribute * attribute) : m_Attribute(attribute) - { - CCompareDlgConstruct(); - m_InitSingleSelect = true; - } - - void CCompareDlgConstruct() - { - m_Attribute->GetHistory(m_History); - m_DiffPath.Create(); - m_LeftPath.Create(); - m_RightPath.Create(); - m_DiffPath.HandsOff(); - m_LeftPath.HandsOff(); - m_RightPath.HandsOff(); - m_SelCount = 0; - } - - ~CCompareDlg() - { - m_DiffPath.HandsOn(); - m_LeftPath.HandsOn(); - m_RightPath.HandsOn(); - } - - enum { IDD = IDD_DIALOG_DIFF }; - - BEGIN_MSG_MAP(thisClass) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_ID_HANDLER_EX(IDOK, OnCloseCmd) - COMMAND_ID_HANDLER_EX(IDCANCEL, OnCloseCmd) - - NOTIFY_HANDLER(IDC_LIST_HISTORY, LVN_ITEMCHANGED, OnLvnItemchangedListHistory) - MESSAGE_HANDLER_EX(CWM_REFRESH, OnRefresh) - CHAIN_MSG_MAP(baseClassDDX) - CHAIN_MSG_MAP(baseClassResize) - END_MSG_MAP() - - BEGIN_DDX_MAP(thisClass) - END_DDX_MAP() - - BEGIN_DLGRESIZE_MAP(thisClass) - DLGRESIZE_CONTROL(IDC_LIST_HISTORY, DLSZ_SIZE_X) - DLGRESIZE_CONTROL(IDC_IE_PLACEHOLDER, DLSZ_SIZE_X | DLSZ_SIZE_Y) - DLGRESIZE_CONTROL(IDC_ECL_PLACEHOLDER, DLSZ_SIZE_X | DLSZ_SIZE_Y) - DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y) - END_DLGRESIZE_MAP() - - LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - void initHistoryList(); - void initIEView(); - void initECLView(); - void OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/); - LRESULT OnRefresh(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/); - - void SetUrl(const CString & url); - void DoRefresh(); - void DoShowSingle(); - void DoShowDouble(); - void DoShowNone(); - LRESULT OnLvnItemchangedListHistory(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/); -}; - -LRESULT CCompareDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) -{ - CenterWindow ( GetParent() ); - - DlgResize_Init(); - - initHistoryList(); - initIEView(); - initECLView(); - - DoDataExchange(); - - return TRUE; -} - -void CCompareDlg::initHistoryList() -{ - int i = 0; - m_HistoryList = GetDlgItem(IDC_LIST_HISTORY); - RECT r; - m_HistoryList.GetWindowRect(&r); - m_HistoryList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - m_HistoryList.AddColumn(_T("Date"), 0); - m_HistoryList.AddColumn(_T("User"), 1); - m_HistoryList.AddColumn(_T("Comment"), 2); - int width = r.right - r.left; - m_HistoryList.SetColumnWidth(0, width / 4); - m_HistoryList.SetColumnWidth(1, width / 4); - m_HistoryList.SetColumnWidth(2, width / 2); - - for(IAttributeHistoryVector::iterator itr = m_History.begin(); itr != m_History.end(); ++itr) - { - m_HistoryList.AddItem(i, 0, itr->get()->GetModifiedDate()); - m_HistoryList.AddItem(i, 1, itr->get()->GetModifiedBy()); - m_HistoryList.AddItem(i, 2, itr->get()->GetDescription()); - ++i; - } - - m_HistoryList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); - if (!m_InitSingleSelect) - m_HistoryList.SetItemState(1, LVIS_SELECTED, LVIS_SELECTED); -} - -void CCompareDlg::initIEView() -{ - CWindow wndPlaceholder = GetDlgItem ( IDC_IE_PLACEHOLDER ); - CRect rc; - - // Get the rect of the placeholder group box, then destroy that window - // because we don't need it anymore. - wndPlaceholder.GetWindowRect ( rc ); - ScreenToClient ( rc ); - wndPlaceholder.DestroyWindow(); - - CComPtr punkCtrl; - - // Create the AX host window. - m_wndIE.Create ( *this, rc, _T(""), WS_CHILD | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE, IDC_IE_PLACEHOLDER ); - - // Create the browser control using its GUID. - m_wndIE.CreateControlEx ( L"{8856F961-340A-11D0-A96B-00C04FD705A2}", NULL, NULL, &punkCtrl ); - - /* - NOTE: You could also use the control's ProgID: Shell.Explorer: - m_wndIE.CreateControlEx ( L"Shell.Explorer", NULL, - NULL, &punkCtrl ); - */ - - // Get an IWebBrowser2 interface on the control and navigate to a page. - m_pWB2 = punkCtrl; -} - -void CCompareDlg::initECLView() -{ - CWindow wndPlaceholder = GetDlgItem(IDC_ECL_PLACEHOLDER); - CRect rc; - wndPlaceholder.GetWindowRect ( rc ); - ScreenToClient(rc); - wndPlaceholder.DestroyWindow(); - m_ecl.Create(*this, rc, _T(""), WS_CHILD | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE, IDC_ECL_PLACEHOLDER); - m_ecl.DoInit(); - m_ecl.SetReadOnly(true); -} - -void CCompareDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/) -{ - EndDialog(wID); -} - -LRESULT CCompareDlg::OnRefresh(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) -{ - DoRefresh(); - return 0; -} - -void CCompareDlg::SetUrl(const CString & url) -{ - CComVariant v; - ATLASSERT(m_pWB2); - m_pWB2->Navigate(CComBSTR(CT2W(url, CP_UTF8)), &v, &v, &v, &v); -} - -void GetHeader(IAttributeHistory * attr, CString & header) -{ - header = (boost::_tformat(_T("%1% (%2%)\n%3%\n")) % attr->GetModifiedDate() % attr->GetModifiedBy() % attr->GetDescription()).str().c_str(); -} - -void CCompareDlg::DoRefresh() -{ - int currentCount = m_HistoryList.GetSelectedCount(); - if (currentCount != m_SelCount) - { - m_SelCount = currentCount; - DoDataExchange(true); - switch (m_HistoryList.GetSelectedCount()) - { - case 1: - DoShowSingle(); - break; - case 2: - DoShowDouble(); - break; - default: - DoShowDouble(); - break; - } - } - - int sel1 = -1, sel2 = -1; - sel1 = m_HistoryList.GetNextItem(sel1, LVNI_SELECTED); - sel2 = m_HistoryList.GetNextItem(sel1, LVNI_SELECTED); - if (m_Sel1 != sel1 || m_Sel2 != sel2) - { - m_Sel1 = sel1; - m_Sel2 = sel2; - if (m_Sel1 != -1 && m_Sel2 != -1) - { - CString left, leftHeader, right, rightHeader; - CWaitCursor(); - GetHeader(m_History[m_Sel1].get(), leftHeader); - left = m_History[m_Sel1]->GetEcl(); - GetHeader(m_History[m_Sel2].get(), rightHeader); - right = m_History[m_Sel2]->GetEcl(); - Compare(leftHeader, left, rightHeader, right, m_DiffPath.TempFileName(), m_LeftPath.TempFileName(), m_RightPath.TempFileName()); - SetUrl(m_DiffPath.TempFileName()); - } - else if (m_Sel1 != -1) - { - CString txtHeader; - CWaitCursor(); - GetHeader(m_History[m_Sel1].get(), txtHeader); - CString txt = "/*"; - txt += txtHeader + _T("*/\r\n"); - txt += m_History[m_Sel1]->GetEcl(); - m_ecl.SetReadOnly(false); - m_ecl.SetText(txt); //TODO: Retest - m_ecl.SetReadOnly(true); - } - } -} - -void CCompareDlg::DoShowSingle() -{ - m_pWB2->put_Visible(false); - m_wndIE.ShowWindow(SW_HIDE); - m_ecl.ShowWindow(SW_SHOW); -} -void CCompareDlg::DoShowDouble() -{ - m_pWB2->put_Visible(true); - m_wndIE.ShowWindow(SW_SHOW); - m_ecl.ShowWindow(SW_HIDE); -} -void CCompareDlg::DoShowNone() -{ - m_pWB2->put_Visible(false); - m_wndIE.ShowWindow(SW_HIDE); - m_ecl.ShowWindow(SW_HIDE); -} - -LRESULT CCompareDlg::OnLvnItemchangedListHistory(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/) -{ - LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR); - if (pNMLV->uChanged & LVIF_STATE) - PostMessage(CWM_REFRESH); - - return 0; -} - -void ShowHistory(IAttribute * attr) -{ - CCompareDlg dlg(attr); - dlg.DoModal(); -} - -void ShowHistory(IAttributeHistory * current, IAttribute * attr) -{ - CCompareDlg dlg(current, attr, true); - dlg.DoModal(); -} - -void ShowCompare(IAttributeHistory * current, IAttribute * attr) -{ - CCompareDlg dlg(current, attr, false); - dlg.DoModal(); -} diff --git a/eclide/HistoryDlg.h b/eclide/HistoryDlg.h deleted file mode 100644 index 80220c19..00000000 --- a/eclide/HistoryDlg.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -__interface IAttributeHistory; -__interface IAttribute; - -void ShowHistory(IAttribute * attr); -void ShowHistory(IAttributeHistory * current, IAttribute * attr); -void ShowCompare(IAttributeHistory * current, IAttribute * attr); - - diff --git a/wlib/HtmlIEView.cpp b/wlib/HtmlIEView.cpp deleted file mode 100644 index 0a2f2502..00000000 --- a/wlib/HtmlIEView.cpp +++ /dev/null @@ -1,401 +0,0 @@ -#include "stdafx.h" - -#include "HTMLView.h" -#include -#include - -const int _nDispatchID = 1; - -#define WM_BROWSERTITLECHANGE (WM_APP) -#define WM_BROWSERDOCUMENTCOMPLETE (WM_APP + 1) -#define WM_BROWSERSTATUSTEXTCHANGE (WM_APP + 2) - -class CHtmlIEView: - public CWindowImpl, - public IDispEventSimpleImpl<_nDispatchID, CHtmlIEView, &DIID_DWebBrowserEvents2>, - public IHtmlView -{ - typedef CHtmlIEView thisClass; - typedef CWindowImpl baseClass; - -protected: - CComPtr m_punkBrowser; - CComPtr m_punkContainer; - CComPtr m_spBrowser; - - std::_tstring m_url; - std::_tstring m_user; - std::_tstring m_pw; - - bool m_bCanGoBack; - bool m_bCanGoForward; - - DWORD m_nProfferAuthenticateCookie; - -public: - DECLARE_WND_SUPERCLASS(_T("TabBrowser_TabPageWindow"), CAxWindow::GetWndClassName()) - // IDispatch events function info - static _ATL_FUNC_INFO DocumentComplete2_Info; - static _ATL_FUNC_INFO Navigate2Complete_Info; - static _ATL_FUNC_INFO TitleChange_Info; - static _ATL_FUNC_INFO StatusTextChange_Info; - static _ATL_FUNC_INFO CommandStateChange_Info; - - CHtmlIEView() : m_bCanGoBack(false), m_bCanGoForward(false)//, m_first(true) - { - m_nProfferAuthenticateCookie = 0; - } - - virtual void OnFinalMessage(_In_ HWND /*hWnd*/) - { - delete this; - } - - HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0) - { - return baseClass::Create(hWndParent, rect, szWindowName, dwStyle, dwExStyle); - } - - BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags) throw() - { - return baseClass::SetWindowPos(hWndInsertAfter, x, y, cx, cy, nFlags); - } - - bool IsLoaded() - { - return m_punkBrowser != 0; - } - - inline bool BackEnabled() const { return m_bCanGoBack; } - inline bool ForwardEnabled() const { return m_bCanGoForward; } - - virtual HRESULT Navigate(const TCHAR *pszUrl, bool newWindow = false) - { - m_url = pszUrl; - DNSLookup(m_url); - CString extraHeaders; - CString auth = m_user.c_str(); - auth += ":"; - auth += m_pw.c_str(); - char buff[256]; - int buffLen = sizeof(buff); - std::string narrowAuth = CT2A(auth); - Base64Encode((BYTE *)narrowAuth.c_str(), narrowAuth.length(), buff, &buffLen); - extraHeaders += "Authorization: Basic "; - extraHeaders += CString(buff, buffLen); - //extraHeaders += "\r\n"; - - _bstr_t url(m_url.c_str()); - CComVariant vTargetFrameName = newWindow ? _T("_blank") : _T("_top"); - CComVariant vFlags; - CComVariant vPostData; - CComVariant vHeaders(extraHeaders); - return m_spBrowser->Navigate(url, &vFlags, &vTargetFrameName, &vPostData, &vHeaders); - } - - virtual void CreateHTMLControl(const TCHAR* pszUrl, const TCHAR* pszUserID, const TCHAR* pszPassword) - { - m_url = pszUrl; - m_user = pszUserID; - m_pw = pszPassword; - if ( !m_punkBrowser ) - { - CreateControlEx( L"{8856F961-340A-11D0-A96B-00C04FD705A2}", NULL, &m_punkContainer, &m_punkBrowser); - if(m_punkBrowser) - { - DispEventAdvise(m_punkBrowser, &DIID_DWebBrowserEvents2); - } - } - - if ( !m_spBrowser ) - { - get_Browser(&m_spBrowser); - } - SetUserAgentString(); - Navigate(pszUrl); - } - - HRESULT get_Control(IUnknown** ppControl) - { - if(m_hWnd != NULL) - { - return CAxWindow::QueryControl(ppControl); - } - return NULL; - } - - HRESULT get_Browser(IWebBrowser2** ppBrowser) - { - if(m_hWnd != NULL) - { - return CAxWindow::QueryControl(ppBrowser); - } - return NULL; - } - - HRESULT put_ServiceProvider(IUnknown* pUnkSite) - { - //this will provide a service provider for all sites - CComPtr spHost; - HRESULT hr = QueryHost(__uuidof(IObjectWithSite), (void**)&spHost); - if (SUCCEEDED(hr)) - hr = spHost->SetSite(pUnkSite); - return hr; - } - - HRESULT put_ProfferService(REFGUID rguidService, IServiceProvider *pServiceProvider) - { - //this will provide a service provider for the current host only - CComPtr spHost; - HRESULT hr = m_punkBrowser->QueryInterface(IID_IServiceProvider, (void**)&spHost); - if (SUCCEEDED(hr)) - { - CComPtr spService; - hr = spHost->QueryService(SID_SProfferService, IID_IProfferService, (void**)&spService); - if (SUCCEEDED(hr)) - { - hr = spService->ProfferService(rguidService, pServiceProvider, &m_nProfferAuthenticateCookie); - } - } - return hr; - } - - void BrowserBack() - { - if (IsLoaded()) { - m_spBrowser->GoBack(); - } - } - - void BrowserForward() - { - if (IsLoaded()) { - m_spBrowser->GoForward(); - } - } - - void BrowserStop() - { - if (IsLoaded()) { - m_spBrowser->Stop(); - } - } - - void BrowserRefresh() - { - if (IsLoaded()) { - m_spBrowser->Refresh(); - } - } - - void BrowserCmdCopy() - { - if (IsLoaded()) { - m_spBrowser->ExecWB(OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); - } - } - - void BrowserCmdSelectAll() - { - if (IsLoaded()) { - m_spBrowser->ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); - } - } - - bool SetUserAgentString() - { - static std::string g_userAgent; - - if (g_userAgent.empty()) - { - char * buff = NULL; - DWORD pdwBufferLengthOut = 0; - HRESULT hr = UrlMkGetSessionOption(URLMON_OPTION_USERAGENT, NULL, 0, &pdwBufferLengthOut, 0); - buff = (char *)malloc(pdwBufferLengthOut); - hr = UrlMkGetSessionOption(URLMON_OPTION_USERAGENT, buff, pdwBufferLengthOut, &pdwBufferLengthOut, 0); - // if (hr == S_OK) API Bug returns E_OUTOFMEMORY on success - { - g_userAgent = buff; - std::_tstring ver; - boost::algorithm::replace_last(g_userAgent, ")", (boost::format("; eclide/%1%)") % static_cast(CT2A(GetAppVersion(ver)))).str()); - } - free(buff); - } - - if (!g_userAgent.empty()) - { - UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, (LPVOID)g_userAgent.c_str(), g_userAgent.length(), 0); - return true; - } - return false; - } - - BOOL PreTranslateMessage(MSG* pMsg) - { - if((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) && - (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST)) - return FALSE; - - BOOL bRet = FALSE; - // give HTML page a chance to translate this message - if(pMsg->hwnd == m_hWnd || IsChild(pMsg->hwnd)) - bRet = (BOOL)SendMessage(WM_FORWARDMSG, 0, (LPARAM)pMsg); - - return bRet; - } - - void SetFocusToHTML() - { - CComPtr spWebBrowser; - HRESULT hRet = QueryControl(IID_IWebBrowser2, (void**)&spWebBrowser); - if(SUCCEEDED(hRet) && spWebBrowser != NULL) - { - CComPtr spDocument; - hRet = spWebBrowser->get_Document(&spDocument); - if(SUCCEEDED(hRet) && spDocument != NULL) - { - CComQIPtr spHtmlDoc = spDocument; - if(spHtmlDoc != NULL) - { - CComPtr spParentWindow; - hRet = spHtmlDoc->get_parentWindow(&spParentWindow); - if(spParentWindow != NULL) - spParentWindow->focus(); - } - } - } - } - -// Event map and handlers - BEGIN_SINK_MAP(CHtmlIEView) - SINK_ENTRY_INFO(_nDispatchID, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnEventDocumentComplete, &DocumentComplete2_Info) - SINK_ENTRY_INFO(_nDispatchID, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, OnEventNavigate2Complete, &Navigate2Complete_Info) - SINK_ENTRY_INFO(_nDispatchID, DIID_DWebBrowserEvents2, DISPID_TITLECHANGE, OnEventTitleChange, &TitleChange_Info) - SINK_ENTRY_INFO(_nDispatchID, DIID_DWebBrowserEvents2, DISPID_STATUSTEXTCHANGE, OnEventStatusTextChange, &StatusTextChange_Info) - SINK_ENTRY_INFO(_nDispatchID, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnEventCommandStateChange, &CommandStateChange_Info) - END_SINK_MAP() - - void __stdcall OnEventDocumentComplete(IDispatch* /*pDisp*/, VARIANT* URL) - { - // Send message to the main frame - ATLASSERT(V_VT(URL) == VT_BSTR); - USES_CONVERSION; - SendMessage(GetTopLevelWindow(), WM_BROWSERDOCUMENTCOMPLETE, (WPARAM)m_hWnd, (LPARAM)OLE2T(URL->bstrVal)); - - //SetFocusToHTML(); - //std::_tstring url = CW2T(URL->bstrVal); - //if (boost::algorithm::equals(m_url, url)) - //{ - // SetFocusToHTML(); - // if (m_first) - // { - // m_first = false; - // BrowserRefresh(); - // } - //} - } - - void __stdcall OnEventNavigate2Complete(IDispatch* /*pDisp*/, VARIANT* URL) - { - // Send message to the main frame - ATLASSERT(V_VT(URL) == VT_BSTR); - USES_CONVERSION; - } - - void __stdcall OnEventTitleChange(BSTR Text) - { - USES_CONVERSION; - SendMessage(GetTopLevelWindow(), WM_BROWSERTITLECHANGE, (WPARAM)m_hWnd, (LPARAM)OLE2CT(Text)); - } - - void __stdcall OnEventStatusTextChange(BSTR Text) - { - USES_CONVERSION; - SendMessage(GetTopLevelWindow(), WM_BROWSERSTATUSTEXTCHANGE, (WPARAM)m_hWnd, (LPARAM)OLE2CT(Text)); - } - - void __stdcall OnEventCommandStateChange(long Command, VARIANT_BOOL Enable) - { - if(Command == CSC_NAVIGATEBACK) - m_bCanGoBack = (Enable != VARIANT_FALSE); - else if(Command == CSC_NAVIGATEFORWARD) - m_bCanGoForward = (Enable != VARIANT_FALSE); - } - -// Message map and handlers - BEGIN_MSG_MAP(CBrowserView) - MESSAGE_HANDLER(WM_CREATE, OnCreate) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) - MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) - END_MSG_MAP() - - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) - { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - - // Connect events - CComPtr spWebBrowser2; - HRESULT hRet = QueryControl(IID_IWebBrowser2, (void**)&spWebBrowser2); - if(SUCCEEDED(hRet)) - { - if(FAILED(DispEventAdvise(spWebBrowser2, &DIID_DWebBrowserEvents2))) - ATLASSERT(FALSE); - } - - // Set host flag to indicate that we handle themes - CComPtr spHost; - hRet = QueryHost(IID_IAxWinAmbientDispatch, (void**)&spHost); - if(SUCCEEDED(hRet)) - { - const DWORD _DOCHOSTUIFLAG_THEME = 0x40000; - hRet = spHost->put_DocHostFlags(DOCHOSTUIFLAG_NO3DBORDER | _DOCHOSTUIFLAG_THEME); - ATLASSERT(SUCCEEDED(hRet)); - } - - return lRet; - } - - LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) - { - // Disconnect events - CComPtr spWebBrowser2; - HRESULT hRet = QueryControl(IID_IWebBrowser2, (void**)&spWebBrowser2); - if(SUCCEEDED(hRet)) - DispEventUnadvise(spWebBrowser2, &DIID_DWebBrowserEvents2); - - bHandled=FALSE; - return 1; - } - - LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) - { - LRESULT lRet = DefWindowProc(uMsg, wParam, lParam); - SetFocusToHTML(); - - return lRet; - } - ////////////////////////////////////////////////////////// - // - static CString GetResourceURL(unsigned nResId) - { - #define fileNameLen 258 - TCHAR fileName[fileNameLen]; - ::GetModuleFileName(ATL::_AtlBaseModule.GetResourceInstance(), fileName, fileNameLen); - TCHAR szURL[360]; - ::wsprintf( szURL, _T("res://%s/%u"), fileName, nResId ); - - return szURL; - - } //GetResourceURL -}; - -__declspec(selectany) _ATL_FUNC_INFO CHtmlIEView::DocumentComplete2_Info = { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, VT_BYREF | VT_VARIANT } }; -__declspec(selectany) _ATL_FUNC_INFO CHtmlIEView::Navigate2Complete_Info = { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, VT_BYREF | VT_VARIANT } }; -__declspec(selectany) _ATL_FUNC_INFO CHtmlIEView::TitleChange_Info = { CC_STDCALL, VT_EMPTY, 1, { VT_BSTR } }; -__declspec(selectany) _ATL_FUNC_INFO CHtmlIEView::StatusTextChange_Info = { CC_STDCALL, VT_EMPTY, 1, { VT_BSTR } }; -__declspec(selectany) _ATL_FUNC_INFO CHtmlIEView::CommandStateChange_Info = { CC_STDCALL, VT_EMPTY, 2, { VT_I4, VT_BOOL } }; - -IHtmlView * CreateIEView() -{ - return static_cast(new CHtmlIEView()); -}