提问人:hjh93 提问时间:4/11/2023 最后编辑:hjh93 更新时间:4/12/2023 访问量:47
程序无法加载到定义的位置
Program won't load in defined location
问:
我无法让程序打开到我的第二个屏幕,以下是我与加载表单相关的内容:
Imports DAL
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.IO
Imports System.Linq
Public Class frmMain
Public Property FormBounds As Rectangle
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim x = 1280
Dim y = 0
'declare 2nd screen as default monitor to open program
'set 1st screen as default if 2nd screen not detected
Dim monitor = If(Screen.AllScreens.Where(Function(scr) Not scr.Primary).FirstOrDefault(), Screen.PrimaryScreen)
Me.FormBounds = monitor
Me.Location = New Point(x, y)
Catch ex As Exception
Me.subErrLog("frmMain_Load", ex.Message)
End Try
End Sub
End Class
出于测试目的,我将 x 和 y 坐标放在代码本身中。但是,当我在连接到显示器作为辅助显示器时,当在我的笔记本电脑上进行测试时,分辨率均为 1280*720,程序会不断加载到第一个屏幕中。
几个星期以来,我一直在为这个问题而烦恼,但我仍然找不到这个问题的原因。
答: 暂无答案
评论
Bounds
Location
Size
Bounds
Location
workarea
WorkingArea
Screen.AllScreens.Where(Function(scr) scr.Primary).First
Screen.PrimaryScreen
Dim monitor = If(Screen.AllScreens.Where(Function(scr) Not scr.Primary).FirstOrDefault(), Screen.PrimaryScreen)
workarea
只是我测试东西时的遗留物。这对我来说也不是自动封顶的,所以我认为它在这里不起作用?WorkingArea