问题描述
我解雇了,当一个事件做到这一点:
I have an event when fired does this:
htmlView.DocumentText = contentArea.Text;
问题是这样的事件激发了很多,我得到了恼人的IE浏览器点击噪音。我见过一个解决方案http://stackoverflow.com/questions/10456/howto-disable-webbrowser-click-sound-in-your-app-only而另外一个,但我pretty新的C夏普(仅在使用它了几个小时),我不确定是什么:
The problem is this event is fired a lot and I get that annoying IE "click noise". I've seen a solution http://stackoverflow.com/questions/10456/howto-disable-webbrowser-click-sound-in-your-app-only and the other one, but I'm pretty new to C Sharp (only been using it for a couple of hours), and am unsure what:
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);
...含义。我在哪里把那个code?对不起,我用C夏普和Visual Studio,并会AP preciate帮助一个新手能理解。
...means. Where do I put that code? Sorry, I'm a noob with C Sharp and Visual Studio and would appreciate help that a neophyte could understand.
谢谢!
推荐答案
您可以把它放在一个静态类里,要么使 CoInternetSetFeatureEnabled
方法公开,或添加其他从更实用的形式,转换参数,如果需要的话后,将其称为电桥法。例如,在第一种情况下这将是:
You can put it inside a static class and either make the CoInternetSetFeatureEnabled
method public, or add an additional bridge method that calls it after converting the parameters from a more usable form, if necessary. For example, in the first case it would be:
public static class UnmanagedCode
{
private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
//etc...
[DllImport("urlmon.dll")]
[PreserveSig]
[return:MarshalAs(UnmanagedType.Error)]
public static extern int CoInternetSetFeatureEnabled(
int FeatureEntry,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
bool fEnable);
}
这篇关于如何禁用单击声音当使用C夏普web浏览器元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!