]> git.saurik.com Git - wxWidgets.git/commitdiff
Disable navigation sounds in wxWebViewIE. This brings the backend into line with...
authorSteve Lamerton <steve.lamerton@gmail.com>
Thu, 2 Feb 2012 20:32:08 +0000 (20:32 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Thu, 2 Feb 2012 20:32:08 +0000 (20:32 +0000)
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
src/msw/webview_ie.cpp

index 9280367daf18fa5b45b6f79fa36326396853b04f..92d0aa11030d0443b4214916f40c1f319e58c794 100644 (file)
@@ -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);
 };
index a48bde92b8ef1869daa3297c4c8b4cf1d88653db..25464fae02909a4c1f5707bd2904acb77ce7139a 100644 (file)
@@ -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;