嘿,所有人,我在這裏看看是否有人會有更好的方式在較少的代碼中完成下面的任務。在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