I have a l33t0 lil function I made so I wouldnt have to do a bunch of **** multiple times...
Heres the API declaration thingys...
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
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 nid As NOTIFYICONDATA
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
Heres the function...
Sub Tray(Form As Form, Systray As Boolean)
On Error Resume Next
Select Case Systray
Case True
Form.mnuTray.Visible = True
Form.Visible = False
With nid
.cbSize = Len(nid)
.hwnd = Form.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Form.Icon
.szTip = Form.Caption & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
Case False
Form.mnuTray.Visible = False
Form.WindowState = 0
Form.Visible = True
Form.Show
Shell_NotifyIcon NIM_DELETE, nid
End Select
End Sub
Put this in the form your gonna be "Traying"
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Sys As Long
Sys = X / Screen.TwipsPerPixelX
Select Case Sys
Case WM_LBUTTONDOWN:
Me.PopupMenu mnuTray
End Select
End Sub
Heres how to use it...
Tray (me, True) - Sticks the form into the tray
Tray (me, False) - Takes the form out.
When the Tray Icon is clicked on it will show mnuTray where you can have **** like "Show" "Exit" etc.
Have fun heh