#include once "window9.bi"

Dim shared note as NOTIFYICONDATA

Function AddSysTrayIcon(ByVal NumberSysTray As Integer,ByVal hwnd As HWND,ByVal icon As HICON, ByRef ToolTipSysTray As USTRING) As Integer export
	note.cbSize = sizeof(NOTIFYICONDATA)
	note.hwnd = hWnd
	note.uID = NumberSysTray
	note.uFlags = NIF_ICON+NIF_MESSAGE+NIF_TIP
	note.uCallbackMessage = 1029
	note.hIcon = icon
	#ifdef UNICODE
		note.szTip= **ToolTipSysTray
	#else	
		note.szTip= ToolTipSysTray
	#EndIf	
	Return Shell_NotifyIcon (NIM_ADD,@note)
End Function

sub ReplaceSysTrayIcon(ByVal NumberSysTray As Integer, ByVal icon As HICON, ByRef ToolTipSysTray As USTRING) Export
	note.cbSize = sizeof(NOTIFYICONDATA)
	note.uID = NumberSysTray
	note.uFlags = NIF_ICON+NIF_MESSAGE+NIF_TIP
	note.uCallbackMessage = 1029
	note.hIcon = icon
	#ifdef UNICODE
		note.szTip= **ToolTipSysTray
	#else	
		note.szTip= ToolTipSysTray
	#EndIf
	Shell_NotifyIcon (NIM_MODIFY,@note)
End Sub

sub DeleteSysTrayIcon(ByVal NumberSysTray As Integer) export
	note.cbSize = sizeof(NOTIFYICONDATA)
	note.uID = NumberSysTray
	Shell_NotifyIcon (NIM_DELETE,@note)
End Sub

Function MessageSysTrayIcon(ByVal NumberSysTray As Integer, ByVal hwnd As HWND, ByRef Title As USTRING, ByRef Text As USTRING, _
							byval Timeout As Integer = 5000, ByVal icon As HICON = 0 , ByVal TypeIcon As Integer = NIIF_INFO) As Integer export
	note.cbSize = sizeof(NOTIFYICONDATA)
	note.hwnd = hWnd
	note.uID = NumberSysTray
	note.uFlags = IIf (icon<>0,NIF_INFO+NIF_ICON,NIF_INFO)
	note.hIcon = icon
	#ifdef UNICODE
		note.szInfo = **Text 
		note.szInfoTitle = **Title  	
	#else	
		note.szInfo = Text 
		note.szInfoTitle = Title  	
	#EndIf
	note.uTimeout = Timeout
	note.dwInfoFlags = TypeIcon
	Return Shell_NotifyIcon (NIM_MODIFY,@note)
End Function


