Кто-нибудь знает, как переместить форму в следующее окно справа (или циклически перемещаться, если текущий монитор является последним) и максимизировать его? Я играю и написал какой-то код (самообучение, поэтому, пожалуйста, будьте добрыми), который перемещает форму, если она находится в «нормальном» окне окна, но я застрял на максимизирующей части. Я бы подумал, что WindowState = Maximized будет делать это, но установка того, что в форме приводит к тому, что функция перемещения не отвечает.VB.NET - Переместить форму на следующий монитор и максимизировать
Ниже приведен код, у меня до сих пор:
Module Monitor
Public totalMonitors As Integer = System.Windows.Forms.Screen.AllScreens.Count
Private xPositionForMonitors As New Dictionary(Of Integer, Integer)
Private yPositionForMonitors As New Dictionary(Of Integer, Integer)
Private currentMonitorIndex As Integer
Private newMonitorIndex As Integer
Public Sub buildMonitorArray()
For m As Integer = 0 To (totalMonitors - 1)
xPositionForMonitors.Add(m, System.Windows.Forms.Screen.AllScreens(m).WorkingArea.Location.X)
yPositionForMonitors.Add(m, System.Windows.Forms.Screen.AllScreens(m).WorkingArea.Location.Y)
Next
End Sub
Public Sub moveToNextMonitor(targWindow As Form)
identifyCurrentMonitor(targWindow)
targWindow.SetDesktopLocation(xPositionForMonitors(newMonitorIndex) + 1, 0)
End Sub
Private Sub identifyCurrentMonitor(targWindow As Form)
For c As Integer = 0 To (totalMonitors - 1)
If targWindow.Location.X + 10 > xPositionForMonitors(c) Then
currentMonitorIndex = c
End If
Next
newMonitorIndex = currentMonitorIndex + 1
If newMonitorIndex = totalMonitors Then newMonitorIndex = 0
End Sub
End Module
В настоящее время я звоню функцию buildMonitorArray по форме нагрузки, а затем с помощью moveToNextMonitor (Me) на форме.
Вы установили WindowState в FormWindowState.Maximized после moveToNextMonitor? – Steve
В Windows 7/8 это просто ключ Windows + клавиша Shift + стрелка вправо, чтобы перейти к монитору справа, а клавиша Windows + стрелка вверх - увеличить. –