My main programming device is a laptop. Because this laptop has a high resolution screen, in the display settings in Windows, I have the setting 'Change the size of text, apps and other items' to 200%. I am developing an application that uses the User32 API in .NET, and use the following code to draw on the screen (I have modified the code to just put random colors on the screen, but my actual application uses images):
<DllImport("User32.dll")>
Public Shared Function GetDC(hwnd As IntPtr) As IntPtr
End Function
<DllImport("User32.dll")>
Public Shared Sub ReleaseDC(hwnd As IntPtr, dc As IntPtr)
End Sub
<DllImport("user32.dll", SetLastError:=False)>
Private Shared Function GetDesktopWindow() As IntPtr
End Function
Sub RandomPixels()
Dim desktopPtr As IntPtr = GetDC(GetDesktopWindow())
Dim g As Graphics = Graphics.FromHdc(desktopPtr)
For x = 0 To 1920
For y = 0 To 1080
Dim b As New SolidBrush(Color.FromArgb(255, rnd.Next(255), rnd.Next(255), rnd.Next(255)))
g.FillRectangle(b, New Rectangle(x, y, 100, 100))
Next
Next
g.Dispose()
ReleaseDC(GetDesktopWindow(), desktopPtr)
End Sub
This, however, only paints in the top left corner of the screen. With experimentation, I have discovered that this only happens when that setting mentioned above is not on 100%.
I have spent hours searching the internet, and have found nothing, so help would be greatly appreciated!
Note: Because this question is basically about the Win32 API, not a specific language, I don't mind what language the answer is in (as long as it is in .NET) :).