我该如何在vb.net中引用屏幕的高度和宽度?例如,右下角的位置,右上角的位置等。
我尝试了My.Computer.Screen
,但找不到任何告诉我尺寸的信息。
我该如何在vb.net中引用屏幕的高度和宽度?例如,右下角的位置,右上角的位置等。
我尝试了My.Computer.Screen
,但找不到任何告诉我尺寸的信息。
你可以使用:
My.Computer.Screen.Bounds
或:Screen.PrimaryScreen.Bounds
Bounds是代表尺寸的矩形。另外,你还可以查看WorkingArea,它不包括任务栏和停靠窗口。
您可以使用如下代码:
My.Computer.Screen.Bounds.Size.Width
My.Computer.Screen.Bounds.Size.Height
对于 WPF,您可以使用:
System.Windows.SystemParameters.PrimaryScreenWidth
System.Windows.SystemParameters.PrimaryScreenHeight
声明高度为整数 = Screen.PrimaryScreen.Bounds.Height 声明宽度为整数 = Screen.PrimaryScreen.Bounds.Width
Dim dw As Double
Dim dh as Double
Width = Screen.PrimaryScreen.Bounds.Width
If (Width = 1366) Then
dw = 1
ElseIf (Width = 1920) Then
dw = 1.4055
ElseIf (Width = 1280) Then
dw = 0.9379
End If
For Each c As Control In Me.Controls
c.Width = CInt(CDbl(c.Width * dw))
Next
Height = My.Computer.Screen.Bounds.Size.Height
If (Height = 768) Then
dh = 1
ElseIf (Height = 1080) Then
dh = 1.4062
ElseIf (Height = 1024) Then
dh = 1.3333
End If
For Each g As Control In Me.Controls
g.Height = CInt(CDbl(g.Height * dh))
Next