Reputation: 71
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.
Upvotes: 1
Views: 433
Reputation: 71
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.
Upvotes: 3