Let's suppose that I have two screens, side by side:
1920x1080
100%
DPI1360x768
125%
DPI
For my Window
, this means:
1920x1080
: Ok1088x614
: Not ok, it's divided by 1,25 because of the scaling factor.
Turning into this:
1920x1080
+1088x614
:3008x1080
I want to use the CopyFromScreen
/BitBlt
methods.
These methods ignore all DPI info, making the Left
and Top
properties (of a window, for example) useless if inside a high dpi screen. Or left to a high dpi screen, since it behaves like 1 screen, example:
So whenever I need to get a screen point from within a set of screens with at least one having a high DPI, it will return a smaller point.
Is there any way to get the true (by true, ignoring the scaling factor) XY info from a set of screens with (at least one) high DPI?
I already tried the managed PointToScreen
and the unmanaged ClientToScreen
methods, both resulting the same "right" point.
Please, read
I want to take screenshots of the screen based of the position of my Window.
I have two monitors, one with 100% DPI, other with 125% DPI.
If my Window is inside the 1st monitor, the screenshot based on the Left/Top properties of my Window works.
If my Window is inside the second monitor, the screenshot won't take the right spot!
Because
The BitBlt
API method ignores the scaling of the screens. Example:
Screenshot of the point 100;100 will be right, because it's inside the 1st screen.
Screenshot of the point 1950;100 won't be right, because it's inside the 2nd screen. Notice that it's 30 pixels to the right.
Why?
As said earlier, for my app, the 125% DPI reduces the screen resolution to 1088x614
, but for the BitBlt
method, it is still 1360x768
.
So I can't convert the Left/Top properties, because it will be wrong, since there is a 100% DPI screen to the left.
Example of the Left
property:
I believe this is the right way to convert:
1920px + 50px: 100% + 125%: 1920 + 62: 1982px
And this is the proposed version:
1920px + 50px: 100% + 125%: 2400 + 62: 2462px
See, if I simple convert the current Left
property based on the DPI of the current Window
, on this case my second screen, I'll also be converting the values of my first screen. This should not happen.