I'm trying to alter the mouse-coordinates returned by the touch-screen. For example, if I have an app that is always full-screen, and the user touches coordinate (1023, 767), then I want the mouse cursor to be at (799, 479). It should be a simple scaling formula, but I can't seem to achieve that. I've tried changing the coordinates in PreTranslateMessage
, but it doesn't seem to have any effect, no matter what I set the values to.
I need to do this at the application level, because I don't have access to the driver/controller level.
Here's a sample of my experiment:
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_LBUTTONUP ||
pMsg->message == WM_MOUSEMOVE)
{
// In this example, I'm simply reducing the "screen" by half.
// I am expecting that the mouse cursor would always be between
// my touch point and the upper-left corner, with a distance of half.
// But nothing seems to be happening. Is pMsg->pt just "read-only"?
pMsg->pt.x = pMsg->pt.x / 2;
pMsg->pt.y = pMsg->pt.y / 2;
}
return CDialog::PreTranslateMessage(pMsg);
}