在 vb.net 中引用屏幕高度和宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1344342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Referencing screen height and width in vb.net
提问by Cyclone
How do I reference the screen height and width in vb.net? For example, the bottom right corner's locations, the top right corner's locations, etc.
如何在 vb.net 中引用屏幕高度和宽度?例如,右下角的位置、右上角的位置等。
I tried My.Computer.Screen
but couldnt find anything that told me the size.
我试过了,My.Computer.Screen
但找不到任何告诉我尺寸的东西。
回答by Reed Copsey
You can use:
您可以使用:
My.Computer.Screen.Bounds
or:
或者:
Screen.PrimaryScreen.Bounds
Boundsis a rectangle that provides the size. Alternatively, you can look at the WorkingArea, which will not include the task bar and docked windows.
Bounds是一个提供大小的矩形。或者,您可以查看WorkingArea,它不包括任务栏和停靠窗口。
回答by Miguel
You can use something like:
你可以使用类似的东西:
My.Computer.Screen.Bounds.Size.Width
My.Computer.Screen.Bounds.Size.Height
回答by donL
For WPF you can use:
对于 WPF,您可以使用:
System.Windows.SystemParameters.PrimaryScreenWidth
System.Windows.SystemParameters.PrimaryScreenHeight
回答by altan yuksel
dim height as integer = Screen.PrimaryScreen.Bounds.Height dim width as integer = Screen.PrimaryScreen.Bounds.Width
暗淡高度为整数 = Screen.PrimaryScreen.Bounds.Height 暗淡宽度为整数 = Screen.PrimaryScreen.Bounds.Width
回答by Boris
Insert this code into form_load. I put some resolutions...
将此代码插入到 form_load 中。我提出了一些决议...
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