'在模块中定义
Public Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONUP = &H205
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIF_MESSAGE = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
'在系统栏添加拖盘
Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'构造系统拖盘结构
TrayIcon.cbSize = Len(TrayIcon)
TrayIcon.hWnd = Me.hWnd
TrayIcon.uId = vbNull
'删除系统栏的拖盘
Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
Unload frmRight
Unload frmDown
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Dim Message As Long
Message = X / Screen.TwipsPerPixelX
'判断鼠标消息,执行不同的功能
Select Case Message
Case WM_LBUTTONDOWN
frmDown.Timer1.Enabled = frmDown.lb_FlagV
frmMain.Show
frmRight.Show
frmDown.Show
frmMain.WindowState = vbNormal
SetForegroundWindow frmMain.hWnd
Case WM_RBUTTONUP
SetForegroundWindow frmMain.hWnd
'PopupMenu mnuPopup
End Select
End Sub