I draw a so-called reversible line in a .NET Framework WinForms app using code like this:
ControlPaint.DrawReversibleLine(
PointToScreen(new Point(x, y1)),
PointToScreen(new Point(x, y2)),
Color.Black);
If high-dpi support is not turned on in the app and the app is launched on a hi-res screen, the x
, y1
and y2
coordinates come from the mouse events as if the app worked on a 96 dpi screen because of the Windows dpi virtualization. But when I pass these numbers to the Control.PointToScreen() function, it processes them taking into account the real resolution of the screen. As a result, the points I get from PointToScreen
are shifted to the left-top corner on the screen on 4K screens.
Is there a simple way to overcome this problem? Please, take into account modern multi-monitor configurations in which every monitor may have its own resolution.