简体   繁体   中英

How to block zooming by Two Fingers Tapping in a Web Browser control

I'm working on a WPF application with an embedded WebBrowser control. And my problem is that users still can zoom pages loaded into the embedded WebBrowser control by Two Fingers Tapping on touchable devices although I have disabled zoom in the CSS file to which every loaded page would be applied:

 -ms-touch-action: pan-y; -ms-content-zooming: none;​ 

I have forced the WebBrowser control to work under IE 11 by specifying in IE Feature Control Registry Setting.

The weird thing here is that the behavior for Two-Fingers-Tapping gesture is different between IE 11 and the embedded WebBrowser control. IE11 does nothing on Two-Fingers-Tapping while the embedded WebBrowser zooms in the loaded page.

To avoid to get answers that I have tried, I would like to list approaches that I have given a shot:

  • viewport setting.

  • Hook WM_GESTURE messages both by System.Windows.Forms.Application.AddMessageFilter(Never received any WM_GESTURE message) and by SetWindowsHookEx(Received WM_GESTURE messages but Internet Explorer Server still can receive WM_GESTURE messages even after returning from the hook function.)

I spent a couple days on the latter one. My guess of the reason failing to keep WM_GESTURE message from the WebBrowser control is that I can not get the handle of the Internet Explorer Server. At the point I receive the message from the hook the Internet Explorer Server already receives and processes it. FYI: The structure of the WebBrowser control I saw via SPY++ is listed below: IEFrame -- Shell DocObject View --- Internet Explorer_Server

Any suggestion is welcome. Thanks in advance.

Change FEATURE_NINPUT_LEGACYMODE DWORD value to 1

You can follow this link for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM