尝试扩展我一直在研究的VB.NET WinForms程序的一些部分。我试图根据分辨率做到这一点,但在Surface 3上遇到了一个问题。
Public Sub GetScreenRes()
Dim screenWidth = Screen.PrimaryScreen.Bounds.Width
Dim screenHeight = Screen.PrimaryScreen.Bounds.Height
MessageBox.Show("Your Screen Resolution is " & screenHeight & "x" & screenWidth)
End Sub
'Output on the message box is "Your screen resolution is 1440 x 960"
'Output should be "Your screen resolution is 2160 x 1440"
我已经仔细检查过,Surface 3上的分辨率设置为2160x1440。
认为这可能与DPI有关,所以我试着检查
Dim dpiX As Single
Dim dpiY As Single
Using g As Graphics = Me.CreateGraphics()
dpiX = g.DpiX
dpiY = g.DpiY
End Using
MessageBox.Show(dpiX & " - " & dpiY)
'Output from that is 96 - 96
DPI为32与我的桌面屏幕相同。所有这些代码都会在我的桌面上返回正确的数字。
我去了这个网站http://dpi.lv/,并将对角线大小调整为23“,我的桌面它给了我96 DPI。在表面上并将对角线大小设置为12”并且它给了我一个DPI 216.