Привет всем, я смотрю здесь, чтобы увидеть, есть ли у кого-нибудь лучший способ выполнить эту задачу ниже в меньшем количестве кода.
Select Case mainMenu.theNumOpened
Case 1
Me.Text = "NBMsg1"
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case 2
Me.Text = "NBMsg2"
Dim hwnd As IntPtr = FindWindow(vbNullString, "NBMsg1")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, Me.Height + 10, 0, 0, 1)
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case 3
Me.Text = "NBMsg3"
Dim hwnd As IntPtr = FindWindow(vbNullString, "NBMsg2")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, Me.Height + 10, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg1")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 2) + 15, 0, 0, 1)
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case 4
Me.Text = "NBMsg4"
Dim hwnd As IntPtr = FindWindow(vbNullString, "NBMsg3")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, Me.Height + 10, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg2")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 2) + 15, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg1")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 3) + 20, 0, 0, 1)
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case 5
Me.Text = "NBMsg5"
Dim hwnd As IntPtr = FindWindow(vbNullString, "NBMsg4")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, Me.Height + 10, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg3")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 2) + 15, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg2")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 3) + 20, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg1")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 4) + 25, 0, 0, 1)
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case 6
Me.Text = "NBMsg6"
Dim hwnd As IntPtr = FindWindow(vbNullString, "NBMsg5")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, Me.Height + 10, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg4")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 2) + 15, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg3")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 3) + 20, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg2")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 4) + 25, 0, 0, 1)
hwnd = FindWindow(vbNullString, "NBMsg1")
SetWindowPos(hwnd, 0, My.Computer.Screen.WorkingArea.Width - 302, (Me.Height * 5) + 30, 0, 0, 1)
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 302, 5)
Case Else
Me.Close()
Me.Dispose()
End Select
Что он делает, так это передает его, теперь многие окна уже открыты. Поэтому, если один, то, конечно, он переходит к случаю 1. Если есть 2 открытых, то он перемещает самый старый вниз и помещает самый новый сверху. и т. д. и т. д. Я установил его так, чтобы максимум 6 ящиков можно было открыть только за один раз.
Если кто-нибудь знает, как я мог бы также «сдвинуть» их вниз (что-то вроде эффекта jQuery), то это также было бы здорово узнать! : О)
Любая помощь / предложения будут великолепны! : О)
David