c-smile
c-smile

Reputation: 27470

How to distinguish WM_MOUSE*** messages generated by touch pad from generated by mouse device?

I've tried GetMessageExtraInfo() mentioned here: Detect if WM_MOUSEMOVE is caused by touch/pen

but it does not work - GetMessageExtraInfo() returns 0 for all mouse events generated by touch pad.

Tried it on notebook with integral touchpad and on desktop PC with external touch pad attached.

I also tried to use WM_TOUCH event with RegisterTouchWindow() and WM_GESTURE but they do not work either - I am not receiving neither WM_TOUCH nor WM_GESTURE events on the window.

Essentially what I need is to detect when finger is on and off touch pad. But it seems that WM_TOUCH or WM_GESTURE work only for touch displays but not for touch pads, for unknown reasons.

Any advice?

Upvotes: 4

Views: 1127

Answers (1)

SoronelHaetir
SoronelHaetir

Reputation: 15172

If you require being able to distinguish the input source, consider using WM_POINTER* messages instead of the older WM_MOUSE* messages. Note that this will require calling EnableMouseInPointer() to receive messages about devices the system considers a mouse (which is true for many basic touch-pads).

Unlike the WM_MOUSE* messages, where the wParam tells you the state of certain virtual keys, the WM_POINTER messages includes enough information to be able to track the input source. It is somewhat more complicated in that pointer messages do not provide separate messages depending on which button was pressed, but that information is at least still available.

Upvotes: 2

Related Questions