home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD14473232001.psc / ModTray.bas < prev    next >
Encoding:
BASIC Source File  |  2001-02-03  |  2.2 KB  |  73 lines

  1. Attribute VB_Name = "Tray"
  2. Option Explicit 'What can I say about it.Needed so that confusion is minimun
  3.  
  4. 'Tip-Use Api declaration loader to be fast. Everything here is there,in Win32api
  5. Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
  6. Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
  7.  
  8. Global Notify As NOTIFYICONDATA
  9. Global BarData As APPBARDATA
  10. Global Const WM_MOUSEMOVE = &H200
  11. Global Const ABM_GETTASKBARPOS = &H5&
  12.  
  13. Type NOTIFYICONDATA
  14.         cbSize As Long
  15.         hwnd As Long
  16.         uId As Long
  17.         uFlags As Long
  18.         ucallbackMessage As Long
  19.         hIcon As Long
  20.         szTip As String * 64
  21. End Type
  22.  
  23. Type APPBARDATA
  24.         cbSize As Long
  25.         hwnd As Long
  26.         ucallbackMessage As Long
  27.         uEdge As Long
  28.         rc As RECT
  29.         lParam As Long
  30. End Type
  31.  
  32. Public Iconobj As Object
  33. Public Const NIM_ADD = &H0
  34. Public Const NIM_MODIFY = &H1
  35. Public Const NIF_MESSAGE = &H1
  36. Public Const NIM_DELETE = &H2
  37. Public Const NIF_ICON = &H2
  38. Public Const NIF_TIP = &H4
  39. Public Const WM_RBUTTONUP = &H205
  40. Public Const WM_LBUTTONDBLCLK = &H203
  41.  
  42.  
  43.  
  44. Public Sub modIcon(frmMain As Form, IconID As Long, icon As Object)
  45.     Dim Result As Long
  46.     Notify.cbSize = 88&
  47.     Notify.hwnd = frmMain.hwnd
  48.     Notify.uId = IconID
  49.     Notify.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
  50.     Notify.ucallbackMessage = WM_MOUSEMOVE
  51.     Notify.hIcon = icon
  52.     Notify.szTip = ""
  53.     Result = Shell_NotifyIcon(NIM_MODIFY, Notify)
  54. End Sub
  55. Public Sub AddIcon(frmMain As Form, IconID As Long, icon As Object)
  56.     Dim Result As Long
  57.     BarData.cbSize = 36&
  58.     Result = SHAppBarMessage(ABM_GETTASKBARPOS, BarData)
  59.     Notify.cbSize = 88&
  60.     Notify.hwnd = frmMain.hwnd
  61.     Notify.uId = IconID
  62.     Notify.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
  63.     Notify.ucallbackMessage = WM_MOUSEMOVE
  64.     Notify.hIcon = icon
  65.     Notify.szTip = "Monitering.." & Chr$(0)
  66.    Result = Shell_NotifyIcon(NIM_ADD, Notify)
  67. End Sub
  68. Public Sub delIcon(IconID As Long)
  69.     Dim Result As Long
  70.     Notify.uId = IconID
  71.     Result = Shell_NotifyIcon(NIM_DELETE, Notify)
  72. End Sub
  73.