home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1997 August / pcpro-0897.iso / code / ProDemo1.bas next >
Encoding:
BASIC Source File  |  1997-05-06  |  2.5 KB  |  81 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. ' Mouse-related API messages
  5. Public Const wm_MouseMove = &H200
  6. Public Const wm_LButtonDown = &H201
  7. Public Const wm_LButtonUp = &H202
  8. Public Const wm_LButtonDblClk = &H203
  9. Public Const wm_RButtonDown = &H204
  10. Public Const wm_RButtonUp = &H205
  11. Public Const wm_RButtonDblClk = &H206
  12. Public Const wm_MButtonDown = &H207
  13. Public Const wm_MButtonUp = &H208
  14. Public Const wm_MButtonDblClk = &H209
  15.  
  16. ' Message constants for call to Shell_NotifyIcon
  17. Public Const Nim_Add = &H0
  18. Public Const Nim_Modify = &H1
  19. Public Const Nim_Delete = &H2
  20.  
  21. ' Flag constants for uFlags field of NotifyIconData
  22. Public Const Nif_Message = &H1
  23. Public Const Nif_Icon = &H2
  24. Public Const Nif_Tip = &H4
  25.  
  26. ' Index constants for Get/SetWindowLong
  27. Public Const Gwl_WndProc = -4
  28. Public Const Gwl_HInstance = -6
  29. Public Const Gwl_HWndParent = -8
  30. Public Const Gwl_Id = -12
  31. Public Const Gwl_Style = -16
  32. Public Const Gwl_ExStyle = -20
  33. Public Const Gwl_UserData = -21
  34.  
  35. ' ID for our callback message
  36. Public Const TrayCallback = 32768
  37.  
  38. Type NotifyIconData
  39.     cbSize As Long
  40.     hWnd As Long
  41.     uID As Long
  42.     uFlags As Long
  43.     uCallbackMessage As Long
  44.     hIcon As Long
  45.     szTip As String * 64
  46. End Type
  47.  
  48. ' Original window procedure
  49. Public OldWndProc As Long
  50.  
  51. Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" _
  52.        (ByVal dwMessage As Long, lpData As NotifyIconData) As Long
  53.  
  54. Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
  55.         (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  56.         
  57. Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
  58.         (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  59.  
  60. Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
  61.         (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, _
  62.         ByVal wParam As Long, ByVal lParam As Long) As Long
  63.  
  64. Public Function FormWindowProc(ByVal hWnd As Long, ByVal Message As Long, _
  65.                    ByVal wParam As Long, ByVal lParam As Long) As Long
  66.                    
  67.     Static TrayLock As Boolean      ' Exclusion lock
  68.     
  69.     If (Message = TrayCallback) And (TrayLock = False) Then
  70.         TrayLock = True
  71.         If lParam = wm_LButtonDown Then
  72.             MsgBox "You clicked the left mouse button on the Tray icon!"
  73.         End If
  74.         TrayLock = False
  75.     End If
  76.     
  77.     FormWindowProc = CallWindowProc(OldWndProc, hWnd, Message, wParam, lParam)
  78. End Function
  79.  
  80.  
  81.