From 9447a0d6af1eb8244f9b434767943df67dc47534 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Thu, 2 Feb 2012 20:32:08 +0000 Subject: [PATCH] Disable navigation sounds in wxWebViewIE. This brings the backend into line with the other backends. Also add a general method for changing INTERNETFEATURELIST settings. See #13694 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70499 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/webview_ie.h | 2 ++ src/msw/webview_ie.cpp | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index 9280367daf..92d0aa1103 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -384,6 +384,8 @@ private: bool CanExecCommand(wxString command) const; void ExecCommand(wxString command); IHTMLDocument2* GetDocument() const; + //Toggles control features see INTERNETFEATURELIST for values. + bool EnableControlFeature(long flag, bool enable = true); wxDECLARE_DYNAMIC_CLASS(wxWebViewIE); }; diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index a48bde92b8..25464fae02 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -87,6 +87,8 @@ bool wxWebViewIE::Create(wxWindow* parent, m_container = new wxIEContainer(this, IID_IWebBrowser2, m_webBrowser, m_uiHandler); + EnableControlFeature(21 /* FEATURE_DISABLE_NAVIGATION_SOUNDS */); + LoadURL(url); return true; } @@ -790,6 +792,44 @@ IHTMLDocument2* wxWebViewIE::GetDocument() const return document; } +bool wxWebViewIE::EnableControlFeature(long flag, bool enable) +{ +#if wxUSE_DYNLIB_CLASS + + wxDynamicLibrary urlMon(wxT("urlmon.dll")); + if( urlMon.IsLoaded() && + urlMon.HasSymbol("CoInternetSetFeatureEnabled") && + urlMon.HasSymbol("CoInternetIsFeatureEnabled")) + { + typedef HRESULT (WINAPI *CoInternetSetFeatureEnabled_t)(DWORD, DWORD, BOOL); + typedef HRESULT (WINAPI *CoInternetIsFeatureEnabled_t)(DWORD, DWORD); + + wxDYNLIB_FUNCTION(CoInternetSetFeatureEnabled_t, CoInternetSetFeatureEnabled, urlMon); + wxDYNLIB_FUNCTION(CoInternetIsFeatureEnabled_t, CoInternetIsFeatureEnabled, urlMon); + + HRESULT hr = (*pfnCoInternetIsFeatureEnabled)(flag, + 0x2 /* SET_FEATURE_ON_PROCESS */); + if((hr == S_OK && enable) || (hr == S_FALSE && !enable)) + return true; + + hr = (*pfnCoInternetSetFeatureEnabled)(flag, + 0x2/* SET_FEATURE_ON_PROCESS */, + (enable ? TRUE : FALSE)); + if ( FAILED(hr) ) + { + wxLogApiError(wxT("CoInternetSetFeatureEnabled"), hr); + return false; + } + return true; + } + return false; +#else + wxUnusedVar(flag); + wxUnusedVar(enable); + return false; +#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS +} + void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt) { if (m_webBrowser == NULL) return;