Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Screen.width/Screen.twipperpixelx-相同的值不同_Vb.net_Screen_Screen Resolution - Fatal编程技术网

Vb.net Screen.width/Screen.twipperpixelx-相同的值不同

Vb.net Screen.width/Screen.twipperpixelx-相同的值不同,vb.net,screen,screen-resolution,Vb.net,Screen,Screen Resolution,我有一个VB应用程序,它在加载时将系统的分辨率从1280*1024更改为1024*768。当我停止应用程序时,它会将分辨率恢复为正常分辨率,该分辨率定义为NormalRes=Screen.Width/Screen.twipperpixelx。但当我第二次同时这样做时,它并没有恢复决议 我检查了代码,返回的分辨率是1024(水平=1280)*1024,因此它无法更改分辨率并保持在1024*768 让我头疼的是,当正常分辨率被定义为Screen.Width/Screen.twipperpixelx时

我有一个VB应用程序,它在加载时将系统的分辨率从1280*1024更改为1024*768。当我停止应用程序时,它会将分辨率恢复为正常分辨率,该分辨率定义为
NormalRes=Screen.Width/Screen.twipperpixelx
。但当我第二次同时这样做时,它并没有恢复决议

我检查了代码,返回的分辨率是1024(水平=1280)*1024,因此它无法更改分辨率并保持在1024*768

让我头疼的是,当正常分辨率被定义为
Screen.Width/Screen.twipperpixelx
时,会出现错误

为什么它给出了不同的值(不是1280而是1024)。是因为当我第一次更改分辨率时,它的值发生了变化吗?
在什么情况下,的值可以有不同的值

寻求您的帮助,
Satish kumar

与其尝试重新计算屏幕分辨率,不如在更改分辨率之前保存分辨率,然后在关闭应用程序时恢复旧分辨率

例如:

Public Class Form1
    Dim oldSize As Size

    Public Sub Form_Load() Handles Form1.Load
        oldSize = Screen.PrimaryScreen.Bounds.Size
    End Sub

    Public Sub Form_Closed() Handles Form1.Closed
        SetScreenResolution(oldSize)
    End Sub

    Public Sub SetScreenResolution(size As Size)
        ' write your code to change the screen size here
    End Sub
End Class

与其尝试重新计算屏幕分辨率,不如在更改分辨率之前保存分辨率,然后在关闭应用程序时恢复旧分辨率

例如:

Public Class Form1
    Dim oldSize As Size

    Public Sub Form_Load() Handles Form1.Load
        oldSize = Screen.PrimaryScreen.Bounds.Size
    End Sub

    Public Sub Form_Closed() Handles Form1.Closed
        SetScreenResolution(oldSize)
    End Sub

    Public Sub SetScreenResolution(size As Size)
        ' write your code to change the screen size here
    End Sub
End Class