我使用此代码获取屏幕尺寸的高度:
Dim hdcSrc As IntPtr = User32.GetWindowDC(handle)
Dim windowRect As New User32.RECT
User32.GetWindowRect(handle, windowRect)
Dim width As Integer = windowRect.right - windowRect.left
Dim height As Integer = windowRect.bottom - windowRect.top
现在,当我们有两台不同尺寸的显示器时。哪个被认为是默认监视器?
答案 0 :(得分:2)
Net Framework中有一个很有用的类可以轻松替换您的代码。
使用
获取主屏幕Screen.PrimaryScreen
例如,上面的代码可以使用
替换Dim area As Rectangle = Screen.PrimaryScreen.Bounds
Console.WriteLine("Width: " & area.Width.ToString)
Console.WriteLine("Height: " & area.Height.ToString)
答案 1 :(得分:0)