我正在尝试更改触摸屏返回的鼠标坐标。例如,如果我有一个始终全屏的应用程序,并且用户触摸坐标 (1023, 767),那么我希望鼠标光标位于 (799, 479)。它应该是一个简单的缩放公式,但我似乎无法实现。我尝试更改 中的坐标PreTranslateMessage
,但无论我将值设置为什么,它似乎都没有任何效果。
我需要在应用程序级别执行此操作,因为我无权访问驱动程序/控制器级别。
这是我的实验样本:
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);
}