home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
-
- ' Mouse-related API messages
- Public Const wm_MouseMove = &H200
- Public Const wm_LButtonDown = &H201
- Public Const wm_LButtonUp = &H202
- Public Const wm_LButtonDblClk = &H203
- Public Const wm_RButtonDown = &H204
- Public Const wm_RButtonUp = &H205
- Public Const wm_RButtonDblClk = &H206
- Public Const wm_MButtonDown = &H207
- Public Const wm_MButtonUp = &H208
- Public Const wm_MButtonDblClk = &H209
-
- ' Message constants for call to Shell_NotifyIcon
- Public Const Nim_Add = &H0
- Public Const Nim_Modify = &H1
- Public Const Nim_Delete = &H2
-
- ' Flag constants for uFlags field of NotifyIconData
- Public Const Nif_Message = &H1
- Public Const Nif_Icon = &H2
- Public Const Nif_Tip = &H4
-
- ' Index constants for Get/SetWindowLong
- Public Const Gwl_WndProc = -4
- Public Const Gwl_HInstance = -6
- Public Const Gwl_HWndParent = -8
- Public Const Gwl_Id = -12
- Public Const Gwl_Style = -16
- Public Const Gwl_ExStyle = -20
- Public Const Gwl_UserData = -21
-
- ' ID for our callback message
- Public Const TrayCallback = 32768
-
- 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
-
- ' Original window procedure
- Public OldWndProc As Long
-
- Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" _
- (ByVal dwMessage As Long, lpData As NotifyIconData) As Long
-
- Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
- (ByVal hWnd As Long, ByVal nIndex As Long) As Long
-
- Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
- (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
-
- Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
- (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, _
- ByVal wParam As Long, ByVal lParam As Long) As Long
-
- Public Function FormWindowProc(ByVal hWnd As Long, ByVal Message As Long, _
- ByVal wParam As Long, ByVal lParam As Long) As Long
-
- Static TrayLock As Boolean ' Exclusion lock
-
- If (Message = TrayCallback) And (TrayLock = False) Then
- TrayLock = True
- If lParam = wm_LButtonDown Then
- MsgBox "You clicked the left mouse button on the Tray icon!"
- End If
- TrayLock = False
- End If
-
- FormWindowProc = CallWindowProc(OldWndProc, hWnd, Message, wParam, lParam)
- End Function
-
-
-