#include #include LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { std::cout << "ID message=" << std::hex << message << std::endl; switch(message) { case WM_DESTROY: PostQuitMessage(0); break; case WM_TOUCH: std::cout << "touch event" << std::endl; break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0L; } HWND InitMessageOnlyWindow(HINSTANCE hInstance, int nCmdShow) { LPWSTR szWindowClassName = TEXT("msgOnly"); WNDCLASSEX windowClass; memset(&windowClass, 0, sizeof(windowClass)); windowClass.cbSize = sizeof(windowClass); windowClass.hInstance = hInstance; windowClass.lpfnWndProc = WndProc; windowClass.lpszClassName = szWindowClassName; if(RegisterClassEx(&windowClass)==0) { std::cerr << "RegisterClass" << std::endl; return 0; } HWND hWindow = CreateWindow( szWindowClassName, L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, NULL); if (!hWindow) { std::cerr << "CreateWindow" << std::endl; return 0; } if(RegisterTouchWindow(hWindow, 0)==0) { std::cerr << "RegisterTouchWindow" << std::endl; return 0; } return hWindow; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWindow = InitMessageOnlyWindow(hInstance, nCmdShow); if(IsTouchWindow(hWindow, 0)) std::cout << "The window is touch enabled." << std::endl; MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; }