locked
How to capture Mouse/Keyboard event in Windows Mobile C++ applications? RRS feed

  • Question

  • Hello,

     

    I am new to Windows mobile applications in C++ with VS 2005. How can I capture Mouse/Keyboard event in WM6.5 applications with C++?

    Please help me ASAP. It can be very needful to me...

     

     

    Thanks & Regards

    Saltriver

    Monday, March 21, 2011 8:04 AM

Answers

  • Hi,

    When someone taps on the screen you get WM_LBUTTONDOWN.
    While someone moves the Stylus or Finger you get WM_MOUSEMOVE.
    When someone releases the tap you get WM_LBUTTONUP.

    Check the sample:

    http://msdn.microsoft.com/en-us/library/bb158669.aspx ( this also gets installed when you install 6.5 DTK).

    (Gestures)

    http://www.codeproject.com/KB/windows/IntroToGesturesAPI.aspx?display=Print

    Regards,

    Malleswar

    Monday, March 21, 2011 9:16 AM
  • It is very similar to PC side Win32 application. you have to use WM_LBUTTONDOWN,WM_MOUSEMOVE,WM_LBUTTONUP to capture mouse events in WinProc.WM_KEYUP and WM_KEYDOWN to capture keyboard events in WinProc.


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    • Marked as answer by Peter_Yu Tuesday, March 29, 2011 2:31 AM
    Monday, March 21, 2011 9:18 AM
  • Hello Saltriver,

    In general, you need to write a callback function for getting Mouse/Keyboard event.

    For example:

    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPAPAM wParam, LPARAM lParam)

    {

    switch(message)

    {

    case WM_LBUTTONDOWN:

    // Add your code;

    break;

    case WM_KEYUP

    //Add your code;

    break;

    ......

    default:

    return DefWindowProc(hWnd, message, wParam, lParam);

    }

    }

    Best regards,

    Avalanc

    • Marked as answer by Peter_Yu Tuesday, March 29, 2011 2:31 AM
    Tuesday, March 22, 2011 3:17 AM

All replies

  • Hi,

    When someone taps on the screen you get WM_LBUTTONDOWN.
    While someone moves the Stylus or Finger you get WM_MOUSEMOVE.
    When someone releases the tap you get WM_LBUTTONUP.

    Check the sample:

    http://msdn.microsoft.com/en-us/library/bb158669.aspx ( this also gets installed when you install 6.5 DTK).

    (Gestures)

    http://www.codeproject.com/KB/windows/IntroToGesturesAPI.aspx?display=Print

    Regards,

    Malleswar

    Monday, March 21, 2011 9:16 AM
  • It is very similar to PC side Win32 application. you have to use WM_LBUTTONDOWN,WM_MOUSEMOVE,WM_LBUTTONUP to capture mouse events in WinProc.WM_KEYUP and WM_KEYDOWN to capture keyboard events in WinProc.


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    • Marked as answer by Peter_Yu Tuesday, March 29, 2011 2:31 AM
    Monday, March 21, 2011 9:18 AM
  • Hello Saltriver,

    In general, you need to write a callback function for getting Mouse/Keyboard event.

    For example:

    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPAPAM wParam, LPARAM lParam)

    {

    switch(message)

    {

    case WM_LBUTTONDOWN:

    // Add your code;

    break;

    case WM_KEYUP

    //Add your code;

    break;

    ......

    default:

    return DefWindowProc(hWnd, message, wParam, lParam);

    }

    }

    Best regards,

    Avalanc

    • Marked as answer by Peter_Yu Tuesday, March 29, 2011 2:31 AM
    Tuesday, March 22, 2011 3:17 AM
  • Hi Avalanc,

     

    Thanks a lot for your help.

    I have achieved my task.

     

    Thanks & Regards

    Saltriver

    Tuesday, March 22, 2011 12:56 PM
  • Thanks for help
    Tuesday, March 22, 2011 12:57 PM