Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get WM_TOUCH messages in a message-only window
    text
    copied!<p>I've just begun a project and I want to receive all the touch events from a touch screen to process them, whichever the active window. I am using the Win32 API with C++ (I am new to Win32 programming). I'd like to use a message-only window but I don't succeed in getting WM_TOUCH message with it (though I think it is properly created and registered for touch events). Here is my function which initialises the message-only window.</p> <pre><code>HWND InitMessageOnlyWindow(HINSTANCE hInstance, int nCmdShow) { LPWSTR szWindowClassName = TEXT("msgOnly"); WNDCLASSEX windowClass; memset(&amp;windowClass, 0, sizeof(windowClass)); windowClass.cbSize = sizeof(windowClass); windowClass.lpfnWndProc = WndProc; windowClass.lpszClassName = szWindowClassName; if(RegisterClassEx(&amp;windowClass)==0) { std::cerr &lt;&lt; "RegisterClass" &lt;&lt; std::endl; return 0; } HWND hWindow = CreateWindow( szWindowClassName, L"", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, 0, 0); if (!hWindow) { std::cerr &lt;&lt; "CreateWindow" &lt;&lt; std::endl; return 0; } if(RegisterTouchWindow(hWindow, 0)==0) { std::cerr &lt;&lt; "RegisterTouchWindow" &lt;&lt; std::endl; return 0; } return hWindow; } </code></pre> <p>I've tested the followings:</p> <ul> <li>to get WM_INPUT messages in the message-only window, it works.</li> <li>to get WM_TOUCH messages in a classic window, it works.</li> </ul> <p>According to this <a href="https://stackoverflow.com/questions/3104509/getting-input-if-the-window-is-not-active-windows">post</a> the message-only window needs to be active. I tried it, the result is odd, SetActiveWindow returns NULL (so there should be a problem) but GetLastError does not hold it. This does not make my program work. I have not dig into the hook thing yet, I'd like to know why this does not work first.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload