]> git.saurik.com Git - wxWidgets.git/commitdiff
Implement IDocHostUIHandler in wxWebViewIE to improve the default behaviour. Disable...
authorSteve Lamerton <steve.lamerton@gmail.com>
Sun, 15 Jan 2012 19:19:00 +0000 (19:19 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Sun, 15 Jan 2012 19:19:00 +0000 (19:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70362 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/webview_ie.h
src/msw/webview_ie.cpp

index f61bf6a8e41d6ea95ee157769b9282d2d8124e26..37f7217676116fb88de2e290c2b6b7dfd552baff 100644 (file)
@@ -480,6 +480,8 @@ MSW:
 - Set wxMenu being closed in wxEVT_MENU_CLOSE events (Marcin Malich).
 - Fix coordinates and Z-position for joystick events (Markus Juergens).
 - Fix size of the font returned by wxTextCtrl::GetStyle() (Igor Korot).
 - Set wxMenu being closed in wxEVT_MENU_CLOSE events (Marcin Malich).
 - Fix coordinates and Z-position for joystick events (Markus Juergens).
 - Fix size of the font returned by wxTextCtrl::GetStyle() (Igor Korot).
+- Add wxActiveXContainer::QueryClientSiteInterface and implement it in
+  wxWebViewIE to improve the default behaviour (Allonii)
 
 OSX:
 
 
 OSX:
 
index 364d8670155440ee1516fd44a5cfffb9de72ca85..3d91636d27c24a4988a7190ed2c0612254286e0b 100644 (file)
@@ -150,9 +150,103 @@ class wxIInternetSession : public IUnknown
 
 /* END OF URLMON.H implementation */
 
 
 /* END OF URLMON.H implementation */
 
+/* Same goes for the mshtmhst.h, these are also taken
+ * from mingw-w64 headers.
+ */
+
+typedef enum _tagwxDOCHOSTUIFLAG
+{
+    DOCHOSTUIFLAG_DIALOG = 0x1,
+    DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x2,
+    DOCHOSTUIFLAG_NO3DBORDER = 0x4,
+    DOCHOSTUIFLAG_SCROLL_NO = 0x8,
+    DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x10,
+    DOCHOSTUIFLAG_OPENNEWWIN = 0x20,
+    DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x40,
+    DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x80,
+    DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x100,
+    DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x200,
+    DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x400,
+    DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x800,
+    DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x1000,
+    DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x2000,
+    DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x4000,
+    DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x10000,
+    DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x20000,
+    DOCHOSTUIFLAG_THEME = 0x40000,
+    DOCHOSTUIFLAG_NOTHEME = 0x80000,
+    DOCHOSTUIFLAG_NOPICS = 0x100000,
+    DOCHOSTUIFLAG_NO3DOUTERBORDER = 0x200000,
+    DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP = 0x400000,
+    DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK = 0x800000,
+    DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL = 0x1000000
+} DOCHOSTUIFLAG;
+
+typedef struct _tagwxDOCHOSTUIINFO
+{
+    ULONG cbSize;
+    DWORD dwFlags;
+    DWORD dwDoubleClick;
+    OLECHAR *pchHostCss;
+    OLECHAR *pchHostNS;
+} DOCHOSTUIINFO;
+
+class wxIDocHostUIHandler : public IUnknown
+{
+public:
+    virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
+                                              IUnknown *pcmdtReserved,
+                                              IDispatch *pdispReserved) = 0;
+
+    virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) = 0;
+
+    virtual HRESULT wxSTDCALL ShowUI(DWORD dwID, 
+                                     IOleInPlaceActiveObject *pActiveObject,
+                                     IOleCommandTarget *pCommandTarget,
+                                     IOleInPlaceFrame *pFrame,
+                                     IOleInPlaceUIWindow *pDoc) = 0;
+
+    virtual HRESULT wxSTDCALL HideUI(void) = 0;
+
+    virtual HRESULT wxSTDCALL UpdateUI(void) = 0;
+    
+    virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) = 0;
+
+    virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) = 0;
+
+    virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) = 0;
+
+    virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
+                                           IOleInPlaceUIWindow *pUIWindow,
+                                           BOOL fRameWindow) = 0;
+
+    virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg, 
+                                                   const GUID *pguidCmdGroup,
+                                                   DWORD nCmdID) = 0;
+
+    virtual HRESULT wxSTDCALL GetOptionKeyPath(__out  LPOLESTR *pchKey, 
+                                               DWORD dw) = 0;
+
+    virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
+                                            IDropTarget **ppDropTarget) = 0;
+
+    virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) = 0;
+
+    virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
+                                           __in __nullterminated  OLECHAR *pchURLIn,
+                                           __out  OLECHAR **ppchURLOut) = 0;
+
+    virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
+                                               IDataObject **ppDORet) = 0;
+};
+
+/* END OF MSHTMHST.H implementation */
+
 struct IHTMLDocument2;
 class wxFSFile;
 class ClassFactory;
 struct IHTMLDocument2;
 class wxFSFile;
 class ClassFactory;
+class wxIEContainer;
+class DocHostUIHandler;
 
 class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
 {
 
 class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
 {
@@ -262,10 +356,11 @@ public:
     DECLARE_EVENT_TABLE();
 
 private:
     DECLARE_EVENT_TABLE();
 
 private:
-    wxActiveXContainer* m_container;
+    wxIEContainer* m_container;
     wxAutomationObject m_ie;
     IWebBrowser2* m_webBrowser;
     DWORD m_dwCookie;
     wxAutomationObject m_ie;
     IWebBrowser2* m_webBrowser;
     DWORD m_dwCookie;
+    DocHostUIHandler* m_uiHandler;
 
     //We store the current zoom type;
     wxWebViewZoomType m_zoomType;
 
     //We store the current zoom type;
     wxWebViewZoomType m_zoomType;
@@ -353,6 +448,69 @@ private:
     wxSharedPtr<wxWebViewHandler> m_handler;
 };
 
     wxSharedPtr<wxWebViewHandler> m_handler;
 };
 
+class wxIEContainer : public wxActiveXContainer
+{
+public:
+    wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL);
+    virtual ~wxIEContainer();
+    virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc);
+private:
+    DocHostUIHandler* m_uiHandler;
+};
+
+class DocHostUIHandler : public wxIDocHostUIHandler
+{
+public:
+    DocHostUIHandler() {};
+    ~DocHostUIHandler() {};
+    virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
+                                              IUnknown *pcmdtReserved,
+                                              IDispatch *pdispReserved);
+    
+    virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo);
+
+    virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
+                                     IOleInPlaceActiveObject *pActiveObject,
+                                     IOleCommandTarget *pCommandTarget,
+                                     IOleInPlaceFrame *pFrame,
+                                     IOleInPlaceUIWindow *pDoc);
+
+    virtual HRESULT wxSTDCALL HideUI(void);
+
+    virtual HRESULT wxSTDCALL UpdateUI(void);
+
+    virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable);
+
+    virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate);
+
+    virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate);
+
+    virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
+                                           IOleInPlaceUIWindow *pUIWindow,
+                                           BOOL fRameWindow);
+
+    virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
+                                                   const GUID *pguidCmdGroup,
+                                                   DWORD nCmdID);
+
+    virtual HRESULT wxSTDCALL GetOptionKeyPath(__out  LPOLESTR *pchKey, 
+                                               DWORD dw);
+
+    virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
+                                            IDropTarget **ppDropTarget);
+
+    virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch);
+
+    virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
+                                           __in __nullterminated  OLECHAR *pchURLIn,
+                                           __out  OLECHAR **ppchURLOut);
+
+    virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
+                                               IDataObject **ppDORet);
+    //IUnknown
+    DECLARE_IUNKNOWN_METHODS;
+};
+
 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
 
 #endif // wxWebViewIE_H
 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
 
 #endif // wxWebViewIE_H
index 17e63ec3f3cf3b458e4e9c7c53e0a2571050bd07..a48bde92b8ef1869daa3297c4c8b4cf1d88653db 100644 (file)
@@ -37,6 +37,7 @@ namespace {
 
 DEFINE_GUID(wxIID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
 DEFINE_GUID(wxIID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
 
 DEFINE_GUID(wxIID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
 DEFINE_GUID(wxIID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
+DEFINE_GUID(wxIID_IDocHostUIHandler, 0xbd3f23c0, 0xd43e, 0x11cf, 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a);
 
 }
 
 
 }
 
@@ -81,7 +82,10 @@ bool wxWebViewIE::Create(wxWindow* parent,
     m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
     m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
 
     m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
     m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
 
-    m_container = new wxActiveXContainer(this, IID_IWebBrowser2, m_webBrowser);
+    m_uiHandler = new DocHostUIHandler;
+    m_uiHandler->AddRef();
+
+    m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler);
 
     LoadURL(url);
     return true;
 
     LoadURL(url);
     return true;
@@ -93,6 +97,8 @@ wxWebViewIE::~wxWebViewIE()
     {
         m_factories[i]->Release();
     }
     {
         m_factories[i]->Release();
     }
+
+    m_uiHandler->Release();
 }
 
 void wxWebViewIE::LoadURL(const wxString& url)
 }
 
 void wxWebViewIE::LoadURL(const wxString& url)
@@ -112,7 +118,7 @@ void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
         param->bstrVal = bstr;
 
         hr = SafeArrayUnaccessData(psaStrings);
         param->bstrVal = bstr;
 
         hr = SafeArrayUnaccessData(psaStrings);
-        
+
         IHTMLDocument2* document = GetDocument();
         document->write(psaStrings);
         document->close();
         IHTMLDocument2* document = GetDocument();
         document->write(psaStrings);
         document->close();
@@ -1155,4 +1161,169 @@ STDMETHODIMP ClassFactory::LockServer(BOOL fLock)
     return S_OK;
 }
 
     return S_OK;
 }
 
+wxIEContainer::wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, 
+                             DocHostUIHandler* uiHandler) :
+    wxActiveXContainer(parent,iid,pUnk)
+{
+    m_uiHandler = uiHandler;
+}
+
+wxIEContainer::~wxIEContainer()
+{
+}
+
+bool wxIEContainer::QueryClientSiteInterface(REFIID iid, void **_interface, 
+                                             const char *&desc)
+{
+    if (m_uiHandler && IsEqualIID(iid, wxIID_IDocHostUIHandler))
+    {
+        *_interface = (IUnknown *) (wxIDocHostUIHandler *) m_uiHandler;
+        desc = "IDocHostUIHandler";
+        return true;
+    }
+    return false;
+}
+
+HRESULT DocHostUIHandler::ShowContextMenu(DWORD dwID, POINT *ppt, 
+                                          IUnknown *pcmdtReserved, 
+                                          IDispatch *pdispReserved)
+{
+    wxUnusedVar(dwID);
+    wxUnusedVar(ppt);
+    wxUnusedVar(pcmdtReserved);
+    wxUnusedVar(pdispReserved);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::GetHostInfo(DOCHOSTUIINFO *pInfo)
+{
+    //don't show 3d border and ebales themes.
+    pInfo->dwFlags = pInfo->dwFlags | DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME;
+    return S_OK;
+}
+
+HRESULT DocHostUIHandler::ShowUI(DWORD dwID,
+                                 IOleInPlaceActiveObject *pActiveObject, 
+                                 IOleCommandTarget *pCommandTarget,
+                                 IOleInPlaceFrame *pFrame,
+                                 IOleInPlaceUIWindow *pDoc)
+{
+    wxUnusedVar(dwID);
+    wxUnusedVar(pActiveObject);
+    wxUnusedVar(pCommandTarget);
+    wxUnusedVar(pFrame);
+    wxUnusedVar(pDoc);
+    return S_FALSE;
+}
+
+HRESULT DocHostUIHandler::HideUI(void)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::UpdateUI(void)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::EnableModeless(BOOL fEnable)
+{
+    wxUnusedVar(fEnable);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
+{
+    wxUnusedVar(fActivate);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
+{
+    wxUnusedVar(fActivate);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::ResizeBorder(LPCRECT prcBorder, 
+                                       IOleInPlaceUIWindow *pUIWindow,
+                                       BOOL fFrameWindow)
+{
+    wxUnusedVar(prcBorder);
+    wxUnusedVar(pUIWindow);
+    wxUnusedVar(fFrameWindow);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::TranslateAccelerator(LPMSG lpMsg, 
+                                               const GUID *pguidCmdGroup,
+                                               DWORD nCmdID)
+{
+    if(lpMsg && lpMsg->message == WM_KEYDOWN)
+    {
+        //control is down?
+        if((GetKeyState(VK_CONTROL) & 0x8000 ))
+        {
+            //skip CTRL-N, CTRL-F and CTRL-P
+            if(lpMsg->wParam == 'N' || lpMsg->wParam == 'P' || lpMsg->wParam == 'F')
+            {
+                return S_OK;
+            }
+        }
+        //skip F5
+        if(lpMsg->wParam == VK_F5)
+        {
+            return S_OK;
+        }
+    }
+
+    wxUnusedVar(pguidCmdGroup);
+    wxUnusedVar(nCmdID);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::GetOptionKeyPath(LPOLESTR *pchKey,DWORD dw)
+{
+    wxUnusedVar(pchKey);
+    wxUnusedVar(dw);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::GetDropTarget(IDropTarget *pDropTarget,
+                                        IDropTarget **ppDropTarget)
+{
+    wxUnusedVar(pDropTarget);
+    wxUnusedVar(ppDropTarget);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::GetExternal(IDispatch **ppDispatch)
+{
+    wxUnusedVar(ppDispatch);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::TranslateUrl(DWORD dwTranslate,
+                                       OLECHAR *pchURLIn,
+                                       OLECHAR **ppchURLOut)
+{
+    wxUnusedVar(dwTranslate);
+    wxUnusedVar(pchURLIn);
+    wxUnusedVar(ppchURLOut);
+    return E_NOTIMPL;
+}
+
+HRESULT DocHostUIHandler::FilterDataObject(IDataObject *pDO, IDataObject **ppDORet)
+{
+    wxUnusedVar(pDO);
+    wxUnusedVar(ppDORet);
+    return E_NOTIMPL;
+}
+
+BEGIN_IID_TABLE(DocHostUIHandler)
+    ADD_IID(Unknown)
+    ADD_RAW_IID(wxIID_IDocHostUIHandler)
+END_IID_TABLE;
+
+IMPLEMENT_IUNKNOWN_METHODS(DocHostUIHandler)
+
 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE