Windows Mobile: disable touch input

Print This Post Print This Post


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 dynamically.

As some have problems implementing a disableTouch, here is my code:

// disabletouch1.cpp : Defines the entry point for the console application.

#include "stdafx.h"

#include "hooks.h"

int _tmain(int argc, _TCHAR* argv[])
        HWND hwnd = GetDesktopWindow();
        DEBUGMSG(1,(L"GetDesktopWindow() = 0x%08x", hwnd));
        long lCmd;
        lCmd = _wtol(argv[1]);

        if(lCmd==1){        //disable touch
            DEBUGMSG(1, (L"+++ TouchRegisterWindow called\n"));
            return m_fpTouchRegisterWindow(hwnd);
        else if (lCmd==0){    //enable touch
            DEBUGMSG(1, (L"--- TouchUnregisterWindow called\n"));
            return GetLastError();
            return -2;//wrong arg
        return -1; //no args no fun
    return 0;

with the first function call being:

HMODULE    m_TouchDLL;
TouchRegisterWindow_t    m_fpTouchRegisterWindow;
TouchUnregisterWindow_t    m_fpTouchUnregisterWindow;
bool InitializeTouchDll() {
    if (m_TouchDLL == NULL) {
        m_TouchDLL = LoadLibrary(L"touch.dll");
        if(m_TouchDLL != NULL) {
            m_fpTouchPanelPowerHandler = (TouchPanelPowerHandler_t)GetProcAddress(m_TouchDLL, L"TouchPanelPowerHandler");
            m_fpTouchRegisterWindow = (TouchRegisterWindow_t)GetProcAddress(m_TouchDLL, _T("TouchRegisterWindow"));
            m_fpTouchUnregisterWindow = (TouchUnregisterWindow_t)GetProcAddress(m_TouchDLL, _T("TouchUnregisterWindow"));
            if ((m_fpTouchPanelPowerHandler != NULL) && (m_fpTouchRegisterWindow != NULL) && (m_fpTouchUnregisterWindow != NULL)) {
                return true; // everything Ok
    } else {
        LOGERROR(L"Error in initializing Touch dll");
        return false;
    LOGERROR(L"Error in finding Touch dll register/unregister functions");
    return false; // something wrong

That is all you need.

Download C source code and VS2008 project file
[Download not found]

Download C source code of DLL to be used from C# or so (just use the exported disableTouch(bool bEnable) function with true or false):
[Download not found]

A set of source code is available at

There are  windows, command line, DLL and CSharp example codes.




  1. arno says:

    Hello. I found code that works fine under WINCE5.x with c# ( Unfortunately Microsoft removed the 2 required entrypoints in TOUCH.DLL under WINCE6.x. Disabling the touch under WINCE6 would be easy (I guess), but for enabling I need a pointer to a function, and I don’t know how to get this pointer. Do you have any ideas?
    Thanks in advance and best regards from Germany

  2. josef says:

    Hello arno

    the solution here should work on WinCE6 too. But if TouchRegisterWindow and TouchUnregisterWindow are not available on WinCE6 we are lost.

    Using DisableTouch is OK, but for EnableTouch we dont have a function to supply.



Leave a Reply