在VB.NET中引用屏幕高度和宽度

8

我该如何在vb.net中引用屏幕的高度和宽度?例如,右下角的位置,右上角的位置等。

我尝试了My.Computer.Screen,但找不到任何告诉我尺寸的信息。

5个回答

14

你可以使用:

My.Computer.Screen.Bounds
或:
Screen.PrimaryScreen.Bounds

Bounds是代表尺寸的矩形。另外,你还可以查看WorkingArea,它不包括任务栏和停靠窗口。


4
你可以使用类似这样的内容:

您可以使用如下代码:

My.Computer.Screen.Bounds.Size.Width
My.Computer.Screen.Bounds.Size.Height

0

对于 WPF,您可以使用:

System.Windows.SystemParameters.PrimaryScreenWidth

System.Windows.SystemParameters.PrimaryScreenHeight

0

声明高度为整数 = Screen.PrimaryScreen.Bounds.Height 声明宽度为整数 = Screen.PrimaryScreen.Bounds.Width


-1
将此代码插入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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接