2010-11-23 6 views
4

Ich habe ein Frame-Element in einem WPF-Fenster und alle Inhalte in meiner Anwendung werden mit Frame.Navigate() geladen. Wenn Sie jedoch zu einer neuen Seite navigieren, wird standardmäßig der Sound wiedergegeben, der in Internet Explorer wiedergegeben wird. Gibt es eine Möglichkeit, wie ich diesen Sound von der Anwendung abwenden kann? Ich möchte die Einstellung in der Systemsteuerung auf OS-Ebene nicht deaktivieren. Danke.Navigationsseiten-Sound in WPF deaktivieren Frame-Steuerelement

Edit: Ich denke, der einzige Weg ist, den Sound auf Betriebssystemebene zu ändern, die in der Registrierung vorgenommen werden kann. Das ist eine akzeptable Lösung für mich.

http://social.msdn.microsoft.com/forums/en-us/vbgeneral/thread/843677F4-8F0B-46CB-986C-92E8042D0707

Antwort

3

Es scheint, dass es keine anderen Möglichkeiten gibt, nur in Windows-Einstellungen zu deaktivieren, wie beschrieben here

+0

http : //social.msdn.microsoft.com/forums/en-us/vbgeneral/thread/843677F4-8F0B-46CB-986C-92E80 42D0707 –

1

Dennis zeigte hier eine Lösung How to disable click sound in WebBrowser Control, aber in meinem Fall hat nicht funktioniert. So modifizierte ich den Code wie unten und jetzt alle gut funktionieren:

Nutzungs

URLSecurityZoneAPI.InternetSetFeatureEnabled(URLSecurityZoneAPI.InternetFeaturelist.DISABLE_NAVIGATION_SOUNDS, URLSecurityZoneAPI.SetFeatureOn.PROCESS, false); 

URLSecurityZoneAPI.vb

''' Enables or disables a specified Internet Explorer feature control 
''' Minimum availability: Internet Explorer 6.0 
''' Minimum operating systems: Windows XP SP2 
Imports System.Runtime.InteropServices 
Imports System.Security 
Imports System 

Friend Class URLSecurityZoneAPI 

    ''' <summary> 
    ''' Specifies where to set the feature control value 
    ''' http://msdn.microsoft.com/en-us/library/ms537168%28VS.85%29.aspx 
    ''' </summary> 
    Public Enum SetFeatureOn As Integer 
     THREAD = &H1 
     PROCESS = &H2 
     REGISTRY = &H4 
     THREAD_LOCALMACHINE = &H8 
     THREAD_INTRANET = &H10 
     THREAD_TRUSTED = &H20 
     THREAD_INTERNET = &H40 
     THREAD_RESTRICTED = &H80 
    End Enum 

    ''' <summary> 
    ''' InternetFeaturelist 
    ''' http://msdn.microsoft.com/en-us/library/ms537169%28v=VS.85%29.aspx 
    ''' </summary> 
    Public Enum InternetFeaturelist As Integer 
     OBJECT_CACHING = 0 
     ZONE_ELEVATION = 1 
     MIME_HANDLING = 2 
     MIME_SNIFFING = 3 
     WINDOW_RESTRICTIONS = 4 
     WEBOC_POPUPMANAGEMENT = 5 
     BEHAVIORS = 6 
     DISABLE_MK_PROTOCOL = 7 
     LOCALMACHINE_LOCKDOWN = 8 
     SECURITYBAND = 9 
     RESTRICT_ACTIVEXINSTALL = 10 
     VALIDATE_NAVIGATE_URL = 11 
     RESTRICT_FILEDOWNLOAD = 12 
     ADDON_MANAGEMENT = 13 
     PROTOCOL_LOCKDOWN = 14 
     HTTP_USERNAME_PASSWORD_DISABLE = 15 
     SAFE_BINDTOOBJECT = 16 
     UNC_SAVEDFILECHECK = 17 
     GET_URL_DOM_FILEPATH_UNENCODED = 18 
     TABBED_BROWSING = 19 
     SSLUX = 20 
     DISABLE_NAVIGATION_SOUNDS = 21 
     DISABLE_LEGACY_COMPRESSION = 22 
     FORCE_ADDR_AND_STATUS = 23 
     XMLHTTP = 24 
     DISABLE_TELNET_PROTOCOL = 25 
     FEEDS = 26 
     BLOCK_INPUT_PROMPTS = 27 
     MAX = 28 
    End Enum 


    ''' <summary> 
    ''' Set the internet feature enabled/disabled 
    ''' </summary> 
    ''' <param name="feature">The feature from <c>InternetFeaturelist</c></param> 
    ''' <param name="target">The target from <c>SetFeatureOn</c></param> 
    ''' <param name="enabled">enabled the feature?</param> 
    ''' <returns><c>true</c> if [is internet set feature enabled] [the specified feature]; otherwise, <c>false</c>.</returns> 
    Public Shared Function InternetSetFeatureEnabled(feature As InternetFeaturelist, target As SetFeatureOn, enabled As Boolean) As Boolean 
     Return (SafeNativeMethods.CoInternetSetFeatureEnabled(CInt(feature), CInt(target), enabled) = 0) 
    End Function 

    ''' <summary> 
    ''' Determines whether the internet feature is enabled. 
    ''' </summary> 
    ''' <param name="feature">The feature from <c>InternetFeaturelist</c></param> 
    ''' <param name="target">The target from <c>SetFeatureOn</c></param> 
    ''' <returns><c>true</c> if the internet feature is enabled; otherwise, <c>false</c>. 
    ''' </returns> 
    Public Shared Function IsInternetSetFeatureEnabled(feature As InternetFeaturelist, target As SetFeatureOn) As Boolean 
     Return (SafeNativeMethods.CoInternetIsFeatureEnabled(CInt(feature), CInt(target)) = 0) 
    End Function 

End Class 

<SuppressUnmanagedCodeSecurityAttribute()> 
Friend NotInheritable Class SafeNativeMethods 

    Private Sub New() 
    End Sub 

    ''' <summary> 
    ''' Enables or disables a specified feature control. 
    ''' http://msdn.microsoft.com/en-us/library/ms537168%28VS.85%29.aspx 
    ''' </summary>    
    <SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("urlmon.dll", ExactSpelling:=True)> 
    Friend Shared Function CoInternetSetFeatureEnabled(featureEntry As Integer, <MarshalAs(UnmanagedType.U4)> dwFlags As Integer, fEnable As Boolean) As <MarshalAs(UnmanagedType.[Error])> Integer 
    End Function 

    ''' <summary> 
    ''' Determines whether the specified feature control is enabled. 
    ''' http://msdn.microsoft.com/en-us/library/ms537164%28v=VS.85%29.aspx 
    ''' </summary> 
    <SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("urlmon.dll", ExactSpelling:=True)> 
    Friend Shared Function CoInternetIsFeatureEnabled(featureEntry As Integer, dwFlags As Integer) As <MarshalAs(UnmanagedType.[Error])> Integer 
    End Function 

End Class 

Hinweis das Hinzufügen von Klasse mit dem Namen SafeNativeMethods