Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to detect touch input globally instead of mouse clicking?

How to detect touch input globally instead of mouse clicking?

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cedricvictor
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • C cedricvictor

      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

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      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 from WPARAM. 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)

      Polymorphism in C

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups