dim ptCursor as POINTAPI If Msg = TRAY_CALLBACK Then
If lParam = WM_LBUTTONUP Then
GetCursorPos ptCursor
'ptCursor.x,ptCursor.y 为您所需(以像素为单位)
frmMenu.Show
frmMenu.move ptCursor.x*15-frmMenu.Width, _
ptCursor.y*15-frmMenu.Height
Exit Function
End If
If lParam = WM_RBUTTONUP Then
GetCursorPos ptCursor
'ptCursor.x,ptCursor.y 为您所需(以像素为单位)
frmMenu.Show
frmMenu.move ptCursor.x*15-frmMenu.Width, _
ptCursor.y*15-frmMenu.Height
Exit Function
End If
End If
If lParam = WM_LBUTTONUP Then
GetCursorPos ptCursor
'ptCursor.x,ptCursor.y 为您所需(以像素为单位)
frmMenu.Show
frmMenu.move ptCursor.x*15-frmMenu.Width, _
ptCursor.y*15-frmMenu.Height
Exit Function
End If
If lParam = WM_RBUTTONUP Then
GetCursorPos ptCursor
'ptCursor.x,ptCursor.y 为您所需(以像素为单位)
frmMenu.Show
frmMenu.move ptCursor.x*15-frmMenu.Width, _
ptCursor.y*15-frmMenu.Height
Exit Function
End If
End If
If Msg = TRAY_CALLBACK Then
If lParam = WM_LBUTTONDBLCLK Then
TheForm.Show
TheForm.SetFocus
Exit Function
End If
If lParam = WM_RBUTTONUP Then
TheForm.PopupMenu TheMenu
Exit Function
End If
End If
NewWindowProc = CallWindowProc( _
OldWindowProc, hwnd, Msg, _
wParam, lParam)
End FunctionPublic Sub AddToTray(frm As Form, mnu As Menu)
Set TheForm = frm
Set TheMenu = mnu
OldWindowProc = SetWindowLong(frm.hwnd, _
GWL_WNDPROC, AddressOf NewWindowProc)
With TheData
.uID = 0
.hwnd = frm.hwnd
.cbSize = Len(TheData)
.hIcon = frm.Icon.Handle
.uFlags = NIF_ICON
.uCallbackMessage = TRAY_CALLBACK
.uFlags = .uFlags Or NIF_MESSAGE
.cbSize = Len(TheData)
.szTip = "Clock"
End With
Shell_NotifyIcon NIM_ADD, TheData
End Sub