Option Explicit
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public 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
Public nid As NOTIFYICONDATA
Private FX As Single
Private FY As Single
Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Const WM_LBUTTONDBLCLK = &H203
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_RBUTTONDBLCLK = &H206
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Public Sub Refresh(ByVal frm As Form)
FX = frm.Width
FY = frm.Height
nid.cbSize = Len(nid)
nid.hwnd = frm.hwnd
nid.uId = vbNull
nid.uflags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = frm.Icon
nid.szTip = App.Title & vbNullChar
Call Shell_NotifyIcon(NIM_ADD, nid)
End Sub
Public Sub Click(ByVal frm As Form, ByVal X As Single)
Dim Msg As Long
Dim sFilter As String
Msg = X / Screen.TwipsPerPixelX
Select Case Msg
Case WM_LBUTTONDOWN
frm.WindowState = 0
frm.Show
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select
End Sub
Public Sub Resize(ByVal frm As Form)
If frm.WindowState = 1 Then
frm.Hide
frm.WindowState = 0
ElseIf frm.WindowState = 0 Then
frm.Show
frm.Width = FX
frm.Height = FY
End If
End Sub
Public Sub Destroy()
Call Shell_NotifyIcon(NIM_DELETE, nid)
End Sub
Now I want, that if i run the program, that the Form1 WONT be visible but will be visible if I hit it in the Tray Icon?
So that it runs into tray, and you can 'open' it from tray..
How to?