PngBall2.AutoSize = False
Call PngBall2.LoadPng("", "GLOBE", "PNG")
PngBall1.LoadPng ("01Alpha_Png.png")
GetWindowRect disables the display zoom (right-click of the program) when the GetWindowRect is set to high DPI, the pixels are not correct, what is the reason?
How to get the check of "Disable display scaling when high DPI setting" is checked
'Check, the desktop size is 3840,2160
'Unchecked, desktop size 1920*1080
Call PngBall2.LoadPng("", "GLOBE", "PNG")
PngBall1.LoadPng ("01Alpha_Png.png")
GetWindowRect disables the display zoom (right-click of the program) when the GetWindowRect is set to high DPI, the pixels are not correct, what is the reason?
How to get the check of "Disable display scaling when high DPI setting" is checked
'Check, the desktop size is 3840,2160
'Unchecked, desktop size 1920*1080
Code:
Public Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
'将客户区坐标系中的点转换为屏幕坐标
Public Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetDesktopWindow Lib "user32" () As Long
Sub Main()
Dim Wnd As Long
Wnd = GetDesktopWindow
Dim WinRect1 As RECT, ClientWh1 As RECT, ClientXY1 As POINTAPI
Dim WinRect2 As RECT, ClientWh2 As RECT, ClientXY2 As POINTAPI
GetWindowRect Wnd, WinRect1
MsgBox "桌面坐标:" & WinRect1.Left & "," & WinRect1.Right & "," & WinRect1.Top & "," & WinRect1.Bottom
'获取【Form】的客户区坐标系(Right=宽度,Bottom=高度),重要,ABCD
GetClientRect Wnd, ClientWh1
'将客户区坐标系中的点p(0,0)转换为屏幕坐标(左上角位置),重要,ABCD
ClientToScreen Wnd, ClientXY1
End Sub