none
急求解答:为什么将网页套入exe中网页的轻扫等手势失效? RRS feed

  • 问题

  • 为什么将网页套入exe中网页的轻扫等手势失效?

    我写了一个测试页面,在里面实现了网页的手势,如轻扫,hold等手势。用IE11打开该测试页面手势都正常。

    但是我把这个页面用c++写的Web Browser控件去打开测试页面,手势竟然都无效?请求高手解决啊!感激不尽!

    手势测试页面代码如下:

    <!DOCTYPE html >
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Gesture Event Firing test</title>
    <style type="text/css">
    .display
    {
      /* Block areas from being selected */
      -ms-user-select: none;
     }
     body
     {
       /* Block area from manipulation actions (zoom, pan) */
    
      touch-action: none;
     }
    
    </style>
    
    <script type="text/javascript">
    //	-ms-touch-action:manipulation double-tap-zoom;
    	var messageId = 0;
    	var redGesture, blueGesture;
    	var redElement, blueElement;
    
    	function printMessage(str) {
    		var element = document.getElementById("output");
    		messageId++;
    		element.value += formatMessage(messageId + ":", 4) + str;
    		element.scrollTop = element.scrollHeight;
    
    		element = document.getElementById("eventCount");
    		element.innerHTML = messageId;
    	}
    
    	function formatMessage(str, len) {
    		var formattedMessage = null;
    		if (str != null) {
    			var formattedMessage = str.toString();
    			formattedMessage += " ";
    			for (var idx = formattedMessage.length; idx < len; idx++) {
    				formattedMessage += " ";
    			}
    		}
    		return formattedMessage;
    	}
    
    	function onLoad() {
    
    		//  Create gesture event listeners for each <div> element
    		prepareTarget("Red", redListener);
    		prepareTarget("Blue", blueListener);
    		// Create MSGesture object 1 (red <div>)
    		redGesture = new MSGesture();
    		redElement = document.getElementById("Red");
    		redGesture.target = redElement;
    		// Create MSGesture object 2 (blue <div>)
    		blueGesture = new MSGesture();
    		blueElement = document.getElementById("Blue");
    		blueGesture.target = blueElement;
    
    		redElement.addEventListener("MSGestureChange", handlegesture);
    		blueElement.addEventListener("MSGestureChange", handlegesture);
    	}
    
    	function handlegesture(e) {
    		if (e.velocityX > 1.5)	//通过滑动速度判断swipe 
    		{
    			alert('swipright');
    		}
    		if (e.velocityX < -1.5)
    		{
    			alert('swipleft');
    		}
    		   
    		if (e.scale > 1)	//直接通过scale信息判断pinch  
    		{
    			alert('pinchout');
    		}
    		else if (e.scale < 1)
    		{
    			alert('pinchin');
    		}
    	}
    
    	//  Add gesture events to an element and point at a specific function
    	function prepareTarget(targetId, eventListener) {
    		var target = document.getElementById(targetId);
    		target.addEventListener("MSGestureStart", eventListener, true);
    		target.addEventListener("MSGestureEnd", eventListener, true);
    		target.addEventListener("MSGestureChange", eventListener, true);
    		target.addEventListener("MSInertiaStart", eventListener, true);
    		target.addEventListener("MSGestureTap", eventListener, true);
    		target.addEventListener("MSGestureHold", eventListener, true);
    		target.addEventListener("pointerdown", eventListener, true);
    	}
    
    	function printEvent(evt) {
    		var str =
    			formatMessage(evt.type, 16) +
    			formatMessage(evt.screenX, 6) +
    			formatMessage(evt.screenY, 6) +
    			formatMessage(evt.clientX.toFixed(0), 6) +
    			formatMessage(evt.clientY.toFixed(0), 6) +
    			formatMessage(evt.translationX.toFixed(2), 8) +
    			formatMessage(evt.translationY.toFixed(2), 8) +
    			formatMessage(evt.scale.toFixed(2), 7) +
    			formatMessage(evt.rotation.toFixed(2), 7) +
    			formatMessage(evt.detail, 5) +
    			formatMessage(evt.currentTarget.id, 10) +
    			formatMessage(evt.srcElement.id, 10) +
    			"\n";
    		printMessage(str);
    		evt.stopPropagation();
    	}
    
    	//  Reset the gesture object
    	function reset() {
    		printMessage("Reset gesture\n");
    		redGesture.reset();
    		blueGesture.reset();
    	}
    	//  Adds a pointer to the MSGesture object for the red square
    	function redListener(evt) {
    		if (evt.type == "pointerdown") {
    			redGesture.addPointer(evt.pointerId);
    			return;
    		}
    		printEvent(evt);
    	}
    	//  Adds a pointer to the MSGesture object for the blue square
    	function blueListener(evt) {
    		if (evt.type == "pointerdown")  // add pointer on pointerdown event
    		{
    			blueGesture.addPointer(evt.pointerId);
    			return;
    		}
    		printEvent(evt);  //  Otherwise pass on event
    	}
    
    	function clearMessages(evt)
    		// Clear the list of gesture messages
    	{
    		var results = document.getElementById("output");
    		results.innerHTML = "";
    		messageId = 0;
    		results = document.getElementById("eventCount");
    		results.innerHTML = messageId;
    	}
    </script>
    </head>
    
    <body id = "page" onload="onLoad()">
        <!-- Elements to try out gestures -->
        <div class= "display" id="Red" style="   width: 300px; height: 250px; background-color: red"></div>
        <div class= "display" id="Blue" style="   width: 300px; height: 250px; background-color: blue"></div>
        <div class= "display" id="control" style="   width: 300px; height: 250px;">
            <button onclick=clearMessages()>Clear Messages</button>
            <br />
            <p>Gesture Event Count: <span id="eventCount"></span></p>
        </div>
    
        <strong><pre><font size="2" face="Courier">
            Type            ScrX  ScrY  CliX  CliY  TrnX    TrnY    Scal   Rotn   Det  Current  Source 
        <textarea id=output rows="18" cols="140" wrap="off" readonly="readonly" ></textarea>
        </font></pre></strong>
    </body>
    </html>
    

    页面效果图:


    环境:

    surface Pro平板电脑。win8.1操作系统,IE11浏览器,vs2012开发软件,C++开发语言


    2014年3月3日 9:00

答案

  • 问题解决

    Windows 8 introduces a new input model that is different from the Windows 7 input model. In order to provide the broadest compatibility for legacy applications, the WebBrowser Control for Windows 8 emulates the Windows 7 mouse, touch, and pen input model (also known as the legacy input model).

    When the legacy input model is in effect, the following conditions are true:

    • Windows pointer messages are not processed by the Trident rendering engine (mshtml.dll).
    • Document Object Model (DOM) pointer and gesture events do not fire.
    • Mouse and touch messages are dispatched according to the Windows 7 input model.
    • Touch selection follows the Windows 7 model ("drag to select") instead of the Windows 8 model ("tap to select").
    • Hardware accelerated panning and zooming is disabled.
    • The Zoom and Pan Cascading Style Sheets (CSS) properties are ignored.

    The FEATURE_NINPUT_LEGACYMODE feature control determines whether the legacy input model is enabled. By default, the feature is disabled for Internet Explorer and enabled for applications hosting the WebBrowser Control. To disable this feature by using the registry, add the name of your executable file to the following setting.

    HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
       SOFTWARE
          Microsoft
             Internet Explorer
                Main
                   FeatureControl
                      FEATURE_NINPUT_LEGACYMODE
                         contoso.exe = (DWORD) 00000000

    The feature is enabled when the value is set to (DWORD) 00000001 and disabled when the value is (DWORD) 00000000.

    • 已标记为答案 zhengbw 2014年3月4日 10:47
    2014年3月4日 10:46

全部回复

  • 你好,

    关于这个问题你可以到IE 或者 mobile develop 论坛去提交,在那你应该可以得到更专业的建议。

    #IE forum

    http://social.msdn.microsoft.com/Forums/ie/en-US/home?category=iedevelopment

    #windows mobile

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=windowsmobiledev%2Cvssmartdevicesvbcs&filter=alltypes&sort=lastpostdesc

    Hope it can help you.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月4日 5:12
  • 问题解决

    Windows 8 introduces a new input model that is different from the Windows 7 input model. In order to provide the broadest compatibility for legacy applications, the WebBrowser Control for Windows 8 emulates the Windows 7 mouse, touch, and pen input model (also known as the legacy input model).

    When the legacy input model is in effect, the following conditions are true:

    • Windows pointer messages are not processed by the Trident rendering engine (mshtml.dll).
    • Document Object Model (DOM) pointer and gesture events do not fire.
    • Mouse and touch messages are dispatched according to the Windows 7 input model.
    • Touch selection follows the Windows 7 model ("drag to select") instead of the Windows 8 model ("tap to select").
    • Hardware accelerated panning and zooming is disabled.
    • The Zoom and Pan Cascading Style Sheets (CSS) properties are ignored.

    The FEATURE_NINPUT_LEGACYMODE feature control determines whether the legacy input model is enabled. By default, the feature is disabled for Internet Explorer and enabled for applications hosting the WebBrowser Control. To disable this feature by using the registry, add the name of your executable file to the following setting.

    HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
       SOFTWARE
          Microsoft
             Internet Explorer
                Main
                   FeatureControl
                      FEATURE_NINPUT_LEGACYMODE
                         contoso.exe = (DWORD) 00000000

    The feature is enabled when the value is set to (DWORD) 00000001 and disabled when the value is (DWORD) 00000000.

    • 已标记为答案 zhengbw 2014年3月4日 10:47
    2014年3月4日 10:46