Click here to Skip to main content
13,260,018 members (49,337 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 25 Sep 2012

Windows Mobile: disable touch input

, 3 Apr 2013
Rate this:
Please Sign up or sign in to vote.
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.  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionUsing it from C# on Windows Mobile Pin
Daniel Siegl13-Nov-12 4:10
memberDaniel Siegl13-Nov-12 4:10 
Also commented on your blog, i tried to code this in C# - yet somehow it will not work!
It will run yet it will not lock the Touchscreen.

Can you give me a hint?
There is Zero documentation and I am very glad you share this with us.
 public static class TouchLock
        [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);
        private static IntPtr DesktopHandle = new IntPtr(0);
        public static Boolean  Lock()
            return TouchRegisterWindow(DesktopHandle);
        public static void UnLock()

Would really appricate if you can help me!

Best Regards from Vienna
AnswerRe: Using it from C# on Windows Mobile Pin
hjgode14-Nov-12 5:32
memberhjgode14-Nov-12 5:32 
AnswerRe: Using it from C# on Windows Mobile Pin
hjgode14-Nov-12 23:30
memberhjgode14-Nov-12 23:30 
GeneralRe: Using it from C# on Windows Mobile Pin
Daniel Siegl15-Nov-12 2:00
memberDaniel Siegl15-Nov-12 2:00 
AnswerRe: Using it from C# on Windows Mobile Pin
hjgode15-Nov-12 20:51
memberhjgode15-Nov-12 20:51 
GeneralRe: Using it from C# on Windows Mobile Pin
Daniel Siegl16-Nov-12 0:10
memberDaniel Siegl16-Nov-12 0:10 
GeneralRe: Using it from C# on Windows Mobile Pin
hjgode16-Nov-12 22:19
memberhjgode16-Nov-12 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 3 Apr 2013
Article Copyright 2012 by hjgode
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid