I'm finding that in Windows 10, the call
dim p as picture =
ScreenshotRectMBS(self.left,self.top,self.width,self.height)
is returning the wrong area of the screen, when running on a display that is
not set at 100% scale factor.
My guess is that your call is using physical pixels rather than logical pixels?
The fix should be just to ask Windows what the scaling factor is and then
adjust the coordinates.
Easy, right?
Not so- many of the APIs lie to you about the dpi scaling.
For example
Dim dpiX As Integer = GetDeviceCaps(hdc, LOGPIXELSX)
Always returns 96
I found one answer that seems to work:
// see
http://stackoverflow.com/questions/5977445/how-to-get-windows-display-settings
Declare Function GetDC Lib "user32" (hWnd As Integer) As Ptr
Declare Function GetDeviceCaps Lib "gdi32" (hdc As Ptr, nIndex As Integer)
As Integer
Declare Sub ReleaseDC Lib "user32" (hWnd As Integer, hdc As Ptr)
const VERTRES = 10
const DESKTOPVERTRES = 117
Dim hdc As Ptr = GetDC(self.Handle)
Dim logicalHeight As Integer = GetDeviceCaps(hdc, VERTRES)
Dim physicalHeight As Integer = GetDeviceCaps(hdc, DESKTOPVERTRES)
ReleaseDC(hwnd, hdc)
Dim scaleFactor As Double = physicalHeight/logicalHeight
dim p as picture = ScreenshotRectMBS(self.left* scaleFactor,self.top*
scaleFactor,self.width* scaleFactor,self.height* scaleFactor)
// the picture may be an odd size, so resize the picture if needed
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info