我调整了之后放入,同时加入了托盘的右键菜单:显示窗口和退出
但是显示窗口点击时要点击两次才能反应,这是什么原因?
Dim nid As NOTIFYICONDATA ' trayicon variable
Sub minimize_to_tray()
Me.Hide
nid.cbSize = Len(nid)
nid.hwnd = Me.hwnd
nid.uId = vbNull
nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = Me.Icon ' the icon will be your Form1 project icon
nid.szTip = "处理平台" & vbNullChar
Shell_NotifyIcon NIM_ADD, nid
End Sub
Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim msg As Long
Dim sFilter As String
msg = X / Screen.TwipsPerPixelX
Select Case msg
Case WM_LBUTTONDOWN
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Case WM_RBUTTONUP
Me.PopupMenu Pomenu
Case WM_RBUTTONDBLCLK
End Select
End Sub
Private Sub MDIForm_Resize()
If Me.WindowState = vbMinimized Then
minimize_to_tray
Else
Shell_NotifyIcon NIM_DELETE, nid
End If
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
Shell_NotifyIcon NIM_DELETE, nid ' del tray icon
End Sub
Private Sub MDIForm_Load()
Shell_NotifyIcon NIM_DELETE, nid ' del tray icon
End Sub
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Shell_NotifyIcon NIM_DELETE, nid ' del tray icon
Unload Me
End Sub
Private Sub showw_click()
Me.Show
Me.WindowState = vbNormal
End Sub
Private Sub quitp_click()
Unload Me
End Sub
[
本帖最后由 linandceline 于 2015-4-30 13:45 编辑 ]