开发者

how to enable and disable touch-screen on Windows-CE or Windows-Mobile?

How to enable and disable touch-screen on Windows-CE or Windows-Mobile 开发者_开发问答?

I need any C# sample code


After hours of googling finally found a correct answer here:

http://www.hjgode.de/wp/2012/09/24/windows-mobile-disable-touch-input/#more-1543

On the bottom you will find a source code on code.google:

https://code.google.com/p/win-mobile-code/source/browse/#svn%2Ftrunk%2FdisableTouch

The actual working source code for c#:

    [DllImport("coredll.dll", SetLastError = true)]
    private static extern IntPtr GetDesktopWindow();

    [DllImport("touch.dll", SetLastError = true)]
    private static extern bool TouchRegisterWindow(IntPtr hwnd);

    [DllImport("touch.dll", SetLastError = true)]
    private static extern void TouchUnregisterWindow(IntPtr hwnd);

    public static Boolean Disable()
    {
        return TouchRegisterWindow(GetDesktopWindow());
    }

    public static void Enable()
    {
        TouchUnregisterWindow(GetDesktopWindow());
    }


The touch screen driver is not like most drivers. It gets loaded directly into GWES at startup and can't easily be "removed" from that infrastructure. There is no common API to enable or disable it, though some OEMs that I've worked with did have an ability to affect the touchpanel driver so you might be able to check with the device OEM if you're targeting a specific device.

You might also consider telling us exactly what it is you're trying to achieve and why and we might be able to offer some other mechanisms to get you where you want. Generally speaking disabling the touchpanel is going to be an unfriendly, bad idea.


Try TouchPanelDisable. Credit goes to Peter Foot:

[DllImport("touch")]
private static extern void TouchPanelDisable();

There is a TouchPanelEnable, but it isn't usable from managed code. So in that scenario, the user would have to do a warm reset to re-enable the panel.

Before you disable touch entirely, have you considered modifying your application to simply ignore events arising from touch input?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜