I've put together some code, which displays a Balloon message for a given SystrayIcon. Now I know this Balloon message can hand me back some user events, which I'd like to process, but I'm too clumsy with Window callbacks, so I'd appreciate some help here.
The MSDN documentation for NOTIFYICONDATA does say something about the events being parsed through the lParam, but it doesn't say which values I should look for when I want to know, for example, when the user has clicked the X on the Balloon message.
EDIT: I just learned that I wanna look for the event values #NIN_BALLOONTIMEOUT, #NIN_BALLOONHIDE and #NIN_BALLOONUSERCLICK, but I still don't know how or where to receive them.
Code: Select all
Structure MY_NOTIFYICONDATA
cbSize.l
hWnd.i
uID.l
uFlags.l
uCallbackMessage.l
hIcon.i
szTip.s{128}
dwState.l
dwStateMark.l
szInfo.s{256}
StructureUnion
uTimeout.l
uVersion.l
EndStructureUnion
szInfoTitle.s{64}
dwInfoFlags.l
EndStructure
Procedure MyCallback(WindowID, Message, wParam, lParam)
If WindowID = WindowID(0)
; I assume I wanna process the event the system sends me here.
EndIf
EndProcedure
OpenWindow(0, 0, 0, 200, 40, "Icontest", #PB_Window_SystemMenu)
ButtonGadget(0, 5, 5, 190, 30, "Show balloon message")
; You might wanna specify a path which corresponds to any valid .ico file on your system.
LoadImage(0, "C:\Programme\PureBasic\Examples\Sources - Advanced\Waponez II\Waponez.ico")
AddSysTrayIcon(0, WindowID(0), ImageID(0))
SysTrayIconToolTip(0, "Naah, I ain't no systray icon, I'm just cleanin' down 'ere.")
;SetWindowCallback(@MyCallback(), 0) ; Uncomment me and - voilá - the button disappears. WTF?
NIData.MY_NOTIFYICONDATA
NIData\cbSize = SizeOf(MY_NOTIFYICONDATA)
NIData\hWnd = WindowID(0)
NIData\uFlags = #NIF_INFO
NIData\szInfo = "I'm just a small speech bubble."
NIData\uTimeout = 15000
NIData\uVersion = #NOTIFYICON_VERSION
NIData\szInfoTitle = "Hey there!"
NIData\dwInfoFlags = #NIIF_INFO
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget
If EventGadget() = 0
Shell_NotifyIcon_(#NIM_MODIFY, NIData)
EndIf
EndIf
Until event = #PB_Event_CloseWindow
Help appreciated!
merendo