سؤال

I've scowered MSDN/Google for the past few days and I've been unable to find the answer to this question.

I'm looking to get the X Y coordinates of a touch/multiple touches on a touchscreen device powered by Windows 8. There are tons of guides on how to add a touch handle to a specific window, but I would like to create an app that relies on touch input, regardless of which window/app is the one in focus/being touched.

Basically, I'm looking for the lowest level touch API out there. Anyone got any ideas? Thanks!

هل كانت مفيدة؟

المحلول

The easy way would be to use the "legacy" (Windows 7) API. With this, you receive the touch input as a WM_TOUCH message.

You use the lParam of that message in a call to GetTouchInputInfo.

That returns an array of TOUCHINPUT structures, each of which includes an x and y coordinate (which, in what seems like it may be a record for useless/illusory precision, is given to a precision of a one-hundredth of a pixel).

For new apps, Microsoft recommends using the Pointer Input API. With this, you'd receive messages like WM_POINTERDOWN, WM_POINTERUP, and WM_POINTERUPDATE. With these, the lParam of the message contains a single x/y point for the input. For more complete information about the location, you'd call GetPointerInfo to retrieve the coordinates of the input in POINTER_INFO structures.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top