如何在 WebBrowser Control 中禁用点击声音 [英] How to disable click sound in WebBrowser Control
本文介绍了如何在 WebBrowser Control 中禁用点击声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 Javascript 单击 webbrowser 控件中的链接.但我不想听到 IE 的咔嗒"声.
I use Javascript to click a link in the webbrowser control. But I don't want to hear IE's "click" sound.
有没有办法做到这一点?
Is there any way to do this?
附言
- 我不想更改系统设置.
- 我见过这个(HowTo Disable WebBrowser 'Click Sound' in your app only)但
Document.写
不是我的选择.
- I don't want to change system settings.
- I've seen this one (HowTo Disable WebBrowser 'Click Sound' in your app only) but
Document.Write
is not an option for me.
推荐答案
IE7及以上可以使用这个:
For IE7 and above, you can use this:
int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS;
CoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true);
使用以下 DLL 导入
using the following DLL imports
private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
private const int SET_FEATURE_ON_THREAD = 0x00000001;
private const int SET_FEATURE_ON_PROCESS = 0x00000002;
private const int SET_FEATURE_IN_REGISTRY = 0x00000004;
private const int SET_FEATURE_ON_THREAD_LOCALMACHINE = 0x00000008;
private const int SET_FEATURE_ON_THREAD_INTRANET = 0x00000010;
private const int SET_FEATURE_ON_THREAD_TRUSTED = 0x00000020;
private const int SET_FEATURE_ON_THREAD_INTERNET = 0x00000040;
private const int SET_FEATURE_ON_THREAD_RESTRICTED = 0x00000080;
...
[DllImport("urlmon.dll")]
[PreserveSig]
[return:MarshalAs(UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled(
int FeatureEntry,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
bool fEnable);
(在 MS 反馈站点上找到,作为 WPF 团队的解决方案:https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345528&wa=wsignin1.0)
(found on the MS feedback site as a solution from the WPF team: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345528&wa=wsignin1.0)
这篇关于如何在 WebBrowser Control 中禁用点击声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文