Why is my panning in Direct 2D drifting at the edge of the window?

Forrest Crawford 60 Reputation points

I'm going through a windows tutorial for Direct 2D drawing a small picture on a render target and I decided to try to add pan and zoom capabilities. All is working mostly fine but I'm having an issue with the pan. My is supposed to move in sync with where the mouse goes while the middle button is held down but it seems to drift the farther you get from the center. I have been messing with this for many hours now and I cannot figure out why it's occurring. Any help will be much appreciated. I've got the source file linked below.


Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,485 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,602 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,066 Reputation points Microsoft Vendor

    According to Taking Advantage of High-Definition Mouse Movement, it should be by design.

    The primary disadvantage to data from WM_MOUSEMOVE is that it is limited to the screen resolution. This means that if you move the mouse slightly — but not enough to cause the pointer to move to the next pixel — then no WM_MOUSEMOVE message is generated. So, using this method to read mouse movement negates the benefits of high-definition input.

    0 comments No comments