Why is Surface Pro pen sending WM_HSCROLL and WM_VSCROLL when the pen is down?

129 Views Asked by At

I'm building a drawing application for Windows desktop (Visual Studio 2019, C++, MFC). I'm using WM_LBUTTONDOWN, WM_MOUSEMOVE and WM_LBUTTONUP to plot pixels when the user is moving the mouse with the left button down.

When I test it on a Surface Pro 4, if I press the pen down on the screen and move - expecting it to draw - the client window scrolls instead. Spy++ shows a lot of WM_HSCROLL and WM_VSCROLL messages going to the window, and the occasional WM_POINTERUPDATE message.

Is there a Win32 API I should be calling to change this behaviour? Or does anyone have any insight into what could be going wrong here?

1

There are 1 best solutions below

0
Torrecto - MSFT On

As IInspectable said, You need to use RegisterTouchWindow to register the created window as touch-capable and handle the meesage of WM_TOUCH to notify the window.