Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
159 views
in Technique[技术] by (71.8m points)

c++ - Coordinates of WM_POINTERDOWN and WM_LBUTTONDOWN Differ

I have found an issue with our Windows 10 application where the X and Y coordinates returned by the Standard Windows message handler for WM_LBUTTONDOWN/WM_LBUTTONUP and WM_POINTERDOWN/WM_POINTERUP differ.

I would expect them to be the same (+/- a few pixels of touch error) but I'm consistently seeing an offset of +50px in the X axis and +65px in the Y axis from WM_POINTERDOWN/WM_POINTERUP. My touch screen has a resolution of 1920px by 1080px. I've added debug to report the returned X and Y coordinates.

If I run my application on my colleague's touchscreen laptop with double the resolution (3840px by 2160px) his machine shows and offset between X & Y returned by WM_LBUTTONDOWN and WM_POINTERDOWN of +100px and +130px respectively. So these offsets seem to be linked to resolution (i.e double my values).

Does anyone know why the X & Y coordinates returned by WM_LBUTTONDOWN and WM_POINTERDOWN or WM_LBUTTONUP & WM_POINTERUP would differ? And if so where is this offset coming from?

I've reset the 'Change the size of text, apps and other items' in my Display settings from '125% (recommended)' to '100%', which has had no effect.

Any suggestions would be much appreciated.

question from:https://stackoverflow.com/questions/65830895/coordinates-of-wm-pointerdown-and-wm-lbuttondown-differ

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Made a breakthrough today.

It seems the X and Y coordinates returned by WM_POINTERDOWN and WM_POINTERUP are absolute coordinates for the entire touchscreen. Whereas the coordinates returned by WM_LBUTTONDOWN and WM_LBUTTONUP are relative to my application's ClientWindow.

So I've had to add some calculations to subtract the application's left and top position (and any title bars & menu bars) from the X and Y coordinates returned by WM_POINTERDOWN and WM_POINTERUP.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...