- int scaledx = wxRound(((float)x / displayx) * 65535);
- int scaledy = wxRound(((float)y / displayy) * 65535);
+ // Casts are safe because x and y are supposed to be less than the display
+ // size, so there is no danger of overflow.
+ DWORD scaledx = static_cast<DWORD>(ceil(x * 65535.0 / (displayx-1)));
+ DWORD scaledy = static_cast<DWORD>(ceil(y * 65535.0 / (displayy-1)));