Bonjour à vous tous et merci d'avance de votre.
Voilà que j'ai réussi à déplacé une form d'un écran à un autre.
Cela fonctionne parfaitement.
Mon soucis est le suivant.
Si la form est en FormWindowState.Maximized
Le code n'agit pas. J'ai tout essayer mais rien à faire.
Voici
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 Private Sub ChangeScreenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeScreenToolStripMenuItem.Click Dim screens() As Screen = Screen.AllScreens Dim currentScreen As Screen = Screen.FromControl(Me) Dim currentScreenIndex As Integer = Array.IndexOf(screens, currentScreen) Dim nextScreenIndex As Integer = currentScreenIndex + 1 If nextScreenIndex = screens.Length Then nextScreenIndex = 0 End If Dim locationInScreenCoordinates As New Point() locationInScreenCoordinates.X = Location.X - currentScreen.Bounds.X locationInScreenCoordinates.Y = Location.Y - currentScreen.Bounds.Y Dim nextScreen As Screen = screens(nextScreenIndex) Dim newLocation As New Point() newLocation.X = 0 newLocation.Y = 0 If Not nextScreen.Bounds.Contains(newLocation) Then If nextScreen.Bounds.Right < newLocation.X Then newLocation.X = nextScreen.Bounds.Right - Width ElseIf newLocation.X < nextScreen.Bounds.Left Then newLocation.X = nextScreen.Bounds.Left End If If newLocation.Y < nextScreen.Bounds.Top Then newLocation.Y = nextScreen.Bounds.Top ElseIf nextScreen.Bounds.Bottom < newLocation.Y Then newLocation.Y = nextScreen.Bounds.Bottom - Height End If End If If Width > nextScreen.Bounds.Width Then Width = nextScreen.Bounds.Width End If If Height > nextScreen.Bounds.Height Then Height = nextScreen.Bounds.Height End If Me.Location = newLocation End Sub
Partager