我知道我可以轻松找到主屏幕的屏幕分辨率,但我想找到我的表单当前所在的屏幕的分辨率(这与我的设置不同,我有三个具有两种不同分辨率的屏幕)
我意识到表单可以跨越多个屏幕,因此我很高兴找到包含表单大部分区域/左上角的屏幕
有没有一种简单的方法可以做到这一点?
我可以枚举屏幕,但要弄清楚我的表单在其中的位置就很棘手:
For Each scr As Screen In Screen.AllScreens
If Me.Left > scr.WorkingArea.Left AndAlso Me.Left < (scr.WorkingArea.Left + scr.WorkingArea.Width) Then 'etc
End If
Next
I know I can find the screen resolution of the Primary screen easily, but I want to find the resolution of the screen that my form is currently sitting in (this is not the same on my setup I have three screens with two different resolutions)
I appreciate that the form could span more than one screen so I would be happy with finding the screen that contains the most area of the form/the top left corner
Is there a simple way to do this?
I can enumerate the screens, but then working out where my form is sitting within this is tricky:
For Each scr As Screen In Screen.AllScreens
If Me.Left > scr.WorkingArea.Left AndAlso Me.Left < (scr.WorkingArea.Left + scr.WorkingArea.Width) Then 'etc
End If
Next
发布评论
评论(1)
。Net为此提供了内置方法
看看Screen.FromControl
.Net provides built-in method for this
Take a look at Screen.FromControl