Hello guys,
I've got two codes, one for SYSTRAY (in a class module) and another for TRAYBALLONTIP (in a module), both working perfectly, (I mean SYSTRAY give me an icon that I implemented some menus, and the TRAYBALLONTIP display me a Tooltip in systray bar with its own icon; so in brief I have two ICON in the systray bar; It's really something that I don't refuz !!!)
The Systray API use
Code:
Code:
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pIconSystray As NOTIFYICONDATA) As Boolean
and TRAYBALLONTIP use this API
Code:
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIF[/sup]YICONDATA) As Boolean
plus
Code:
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
and this is the whole code for the TRAYBALLONTIP in Module :
Code:
'Notice the changes here from the old 'standard' NOTIFYICONDATA
Public Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type
Public Const NOTIFYICON_VERSION = 3 'V5 style taskbar
Public Const NOTIFYICON_OLDVERSION = 0 'Win95 style taskbar
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIM_SETFOCUS = &H3
Public Const NIM_SETVERSION = &H4
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const NIF_STATE = &H8
Public Const NIF_INFO = &H10
Public Const NIS_HIDDEN = &H1
Public Const NIS_SHAREDICON = &H2
Public Const NIIF_NONE = &H0
Public Const NIIF_WARNING = &H2
Public Const NIIF_ERROR = &H3
Public Const NIIF_INFO = &H1
Public Const NIIF_GUID = &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 Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
another TRAYBALLONTIP code in GENERAL DECLARATION Section of the mainForm :
Code:
Private m_IconData As NOTIFYICONDATA
and the last TRAYBALLONTIP code in the mainForm to handle the event "MINIMIZE WINDOW", when the user try to minimize the window the TRAYBALLONTIP display a tooltip to inform, with message "the window has been minimized on the systray bar"
Code:
'Set up the structure
' IF szInfoTitle and szInfo are not terminated with 'null' the box is huge!
With m_IconData
.cbSize = Len(m_IconData)
.hWnd = Me.hWnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_INFO Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
'.szTip = "Your Message Here" & vbNullChar
.dwState = 0
.dwStateMask = 0
.szInfo = " L'application est minimisée dans la zone de notification" & Chr(0)
.szInfoTitle = " Dictionnaire " & Chr(0)
.dwInfoFlags = NIIF_INFO
.uTimeout = 3000
End With
Shell_NotifyIcon NIM_ADD, m_IconData
Shell_NotifyIcon NIM_MODIFY, m_IconData
I tried to work on it with the aim of having only two APIs, instead of 3, and the whole in a module, but I failled, as I'm not really very EXCELLENT in this staff.
My concern is : I need to implement a SYSTRAY with the same code of TRAYBALLONTIP.
If you need more details about it, do not hesitate to ask me.
Please How to do???