Note that there are some explanatory texts on larger screens.

plurals
  1. POWM_POINTER and High DPI settings
    text
    copied!<p>I've been working for a while with the Windows 8 Touch API (<strong>WM_POINTERDOWN</strong> / <strong>WM_POINTERUPDATE</strong> / <strong>WM_POINTERUP</strong>) on a desktop touch screen. Then I tried my test program on a Windows 8 tablet and found out that my application was not able to detect accurately where the user was touching the screen.</p> <p>Using the mouse on the other hand, worked fine: I got the correct coordinates. Since I have the <em>EnableMouseInPointer(TRUE)</em> mode active it means that the same code is being used to process the mouse events and the touch events, which at least means that my code is somewhat working correctly.</p> <p>What I found out, is that the tablets have the High DPI mode enabled to make it possible for the users to touch what would be otherwise very small on the screen. When I changed the DPI on the tablet to remove the scaling my application worked fine, when I upped the DPI on my desktop screen things got wrong. <em>(And yes, my application is High DPI Aware)</em></p> <p>The annoying thing is that apparently the coordinates I receive from the touch interface are not the same depending of the device used:</p> <ul> <li>if the user used the mouse, the coordinates are scaled to take into consideration the High DPI scaling.</li> <li>if the user used the touch screen, the coordinates are not scaled and are in physical pixels</li> </ul> <p>So, what would be the correct way to handle that?</p> <p>An obvious hack would be to check the <em>pointerType</em> member of the <strong>POINTER_INFO</strong> struct, and apply some rescaling depending of the type (<strong>PT_TOUCH</strong> or <strong>PT_MOUSE</strong>), but as far as I could see it is not documented anywhere, and for example I have no idea if a <strong>PT_PEN</strong> should be rescaled or not.</p> <p>That does not seem very elegant and future proof.</p> <p>Any suggestion on how to do that cleanly would be welcome.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload