Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Windows Mobile: disable touch input

0.00/5 (No votes)
3 Apr 2013 2  
Hello sometimes you might want to 'lock' the screen, or to put it another way: disable touch input.

sometimes you might want to ‘lock’ the screen, better say: disable touch input. For example, if you put the device in a pocket, to avoid accidentally tapped screen elements.

It took me a long time and deep searches and trials to find out, how that could be done. Beside there is a API function called DisableTouch, you need to reboot to re-enable touch screen input. The corresponding API EnableTouch() needs a function pointer as callback for touch input processing. How could you provide some?

Fortunately I found TouchRegisterWindow and TouchUnregisterWindow. Although I do not know exactly what they are for and there is NO documentation to find anywhere. The only references I found was about transcriber input and at the TouchLockPro code. 

I managed to use the functions easily after some digging in the TouchLockPro (sourceforge project) code. TouchLockPro disables touch screen input by creating a window of zero size and registering this with TouchRegisterWindow. The WndProc of this zero size window does nothing and the screen is ‘blocked’ for touch input.

But there is an easier use: you can just register the desktop window handle of Windows Mobile. If you use it with TouchRegisterWindow(), the touch input is no more forwarded to the mobile screen elements. To ‘unlock’ touch screen input, you just have to call TouchUnregisterWindow() with the handle of the desktop window (GetDesktopWindow()).

Looking thru the window list with CE remote Spy you will see two Desktop windows:

   

GetDesktopWindow() will return the non-zero one.

Now, you know an easy way to lock and unlock the touch screen input.

If you are coding a kiosk mode app, it may be easier to just code some ‘ignore input’ function without using TouchRegisterWindow and TouchUnregisterWindow of touch.dll.

BTW: you should use these two functions with dynamically.  

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here