How to detect touch input globally instead of mouse clicking?
-
Dear all: I try to use hook to detect touch input globally. I using WH_CALLWNDPROC of hook to detect and write in dll. I use hook like this
g_hInstance = AfxGetInstanceHandle();
g_hPreviousHook = SetWindowsHookEx(WH_CALLWNDPROC, &CallWndProc,g_hInstance, 0);
and in my CallWndProc process
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(0 > nCode)
return CallNextHookEx(g_hPreviousHook, nCode,
wParam, lParam);PMSG msg = (PMSG) lParam; UINT32 pointerId = GET\_POINTERID\_WPARAM(wParam); POINTER\_INPUT\_TYPE pointerType; //GetPointerType(pointerId, &pointerType); return CallNextHookEx(g\_hPreviousHook, nCode, wParam, lParam);
}
when I add the GetPointerType(pointerId, &pointerType) into the code and debug, it will load the dll failed and occur debug assert failed, and jump into appmodul.cpp.Jump into
extern int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, int nCmdShow);
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,_In_ LPTSTR lpCmdLine, int nCmdShow)
#pragma warning(suppress: 4985)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}when I disable GetPointerType(pointerId, &pointerType) , the application work fine. I don't know what happen, Does anybody try to use this or know why? Thank for your help, Victor
-
Dear all: I try to use hook to detect touch input globally. I using WH_CALLWNDPROC of hook to detect and write in dll. I use hook like this
g_hInstance = AfxGetInstanceHandle();
g_hPreviousHook = SetWindowsHookEx(WH_CALLWNDPROC, &CallWndProc,g_hInstance, 0);
and in my CallWndProc process
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(0 > nCode)
return CallNextHookEx(g_hPreviousHook, nCode,
wParam, lParam);PMSG msg = (PMSG) lParam; UINT32 pointerId = GET\_POINTERID\_WPARAM(wParam); POINTER\_INPUT\_TYPE pointerType; //GetPointerType(pointerId, &pointerType); return CallNextHookEx(g\_hPreviousHook, nCode, wParam, lParam);
}
when I add the GetPointerType(pointerId, &pointerType) into the code and debug, it will load the dll failed and occur debug assert failed, and jump into appmodul.cpp.Jump into
extern int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, int nCmdShow);
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,_In_ LPTSTR lpCmdLine, int nCmdShow)
#pragma warning(suppress: 4985)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}when I disable GetPointerType(pointerId, &pointerType) , the application work fine. I don't know what happen, Does anybody try to use this or know why? Thank for your help, Victor
You're not installing a mouse hook. Rather, you're installing a
CallWndProc
hook. From this hook proc, you're trying to get the pointer Id fromWPARAM
. The documentation of CallWndProc[^] says - Type: WPARAM Specifies whether the message was sent by the current thread. If the message was sent by the current thread, it is nonzero; otherwise, it is zero. I'm guessing you should use MouseProc[^] here.«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)