Sunday, March 10, 2019

MouseEventArgs coordinates are relative to the visible region

Today I did some tinkering involving a Windows Forms Panel that can be scrolled. To allow dragging things rendered on it, I had a MouseMove handler that used the coordinates given in the event arguments to figure out what and where to drag. I found that the drag-and-drop feature developed bizarre behavior as soon as the panel was scrolled away from the origin. Apparently, the coordinate in the event arguments are relative to the upper-left of the visible region of the panel, not the entire panel area.

No comments:

Post a Comment