具体一些,是用 SH_NotifyIcon 函数,和一个 SHNOTIFYICONDATA 类型就可以了。不过要是使托盘有功能,那就更加复杂了,需要自己创建一个程序窗口事件处理过程。下面是我一个中型程序的托盘代码:
Public lOrgWindowProc As Long
Public Function NewWindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'窗口与托盘消息处理过程
With frmMainWindow
If uMsg = TRAY_CALLBACK Then
If lParam = WM_LBUTTONUP Then
.WindowState = IIf(.WindowState = vbMinimized, vbMaximized, vbMinimized)
.Show
Exit Function
ElseIf lParam = WM_RBUTTONUP Then
.PopupMenu .mnuPopupMenu2, , , , .mnuPopupMenu2Menus(0)
Exit Function
End If
Else
If uMsg = WM_NCRBUTTONDOWN Then
.PopupMenu .mnuManaging
Exit Function
End If
End If
End With
NewWindowProc = CallWindowProc(lOrgWindowProc, hwnd, uMsg, wParam, lParam)
End Function