嘿,所有人,我在这里看看是否有人会有更好的方式在较少的代码中完成下面的任务。在VB.net代码中简化CASE代码
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的效果),那么这也将是,很好的知道! :o)
任何帮助/建议将是伟大的! :O)
大卫
任何人有任何建议添加修复? – StealthRT 2010-05-05 01:50:03