Reply To: systemtray

#190944
Locohacker
Administrator

Well I found this on I dont understand it tho, but thats an example they gave 😕

Option Explicit

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" ( _
ByVal dwMessage As Long, _
pnid As NOTIFYICONDATA) _
As Long

Private 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

Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_RBUTTONUP = &H205

Private Sub Form_Load()
Dim NID As NOTIFYICONDATA

'Set the data
With NID
.cbSize = Len(NID)
.hIcon = Me.Icon
.hWnd = Me.hWnd
.szTip = "Tray Application" & vbNullChar
.ucallbackMessage = WM_LBUTTONDBLCLK
.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
.uId = 1&
End With
'Add the Icon
Shell_NotifyIcon NIM_ADD, NID
End Sub

Private Sub Command1_Click()
Shell_NotifyIcon NIM_DELETE, NID
End Sub