`WebBrowserShortcutsEnabled = false` ignorado cuando se implementa IOLE SetClientSite

Estoy estableciendo WebBrowserShortcutsEnabled a false in order to disable typical Internet Explorer shortcuts in my System.Windows.Forms.WebBrowser implementation. This works fine until I also implement IOLEClientSite y llamar al SetClientSite usando el siguiente código:

IOLEObject o = (IOLEObject)this.ActiveXInstance;

If I remove this code, it works and shortcuts are properly disabled. What's going on here?

preguntado el 04 de marzo de 14 a las 13:03

2 Respuestas

WebBrowser is an ActiveX control. It negotiates with its host to deal with UI implementation details like shortcut keystrokes. It needs to tell the host about it first since the host may want to use the shortcut for its own use.

The normal host is implemented by the internal WebBrowserSite class, derived from WebBrowserSiteBase. You replaced it, now it is your job to implement that negotiation. This is done by IDocHostUIHandler::TranslateAccelerator(), simply return S_OK from your implementation of this method. Which tells the browser that it should not process the keystroke itself.

respondido 04 mar '14, 15:03

When you override the base functionality of WebBrowser OLE site object, you're at risk of breaking some existing features. You should consult with .NET reference source code para WebBrowser implementation details which might be affected by your custom site.

Ideally, you should be calling the base site implementation when you override any COM interfaces, which might be tricky, because the most of COM interfaces implemented by .NET are declared as internal.

I dealt with a similar problem aquí y aquí.

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.