Re: SysTrayIcon disappear
Posted: Sat Feb 20, 2021 11:34 pm
Try this, you should get a custom notification when the taskbar restarts. (You can simulate it by killing explorer and then using the run option in task manager to restart it). Its not a solution but at the very least it should help you work out if its a taskbar restart that's causing the problem. If it is, it should allow you to handle the failure more gracefully.
Code: Select all
; Change this if you're already using custom events.
#TaskbarCreated = #PB_Event_FirstCustomValue
Define.S sMessage = "TaskbarCreated"
Define.I uTaskbarRestart = RegisterWindowMessage_(@sMessage)
Procedure WinCallback(hWnd, uMsg, WParam, LParam)
Shared uTaskbarRestart
If uMsg = uTaskbarRestart
; You need to alter the parameters to provide the right window number (the first zero, second parameter, in this line).
PostEvent(#TaskbarCreated, 0, 0)
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 0, 0, 200, 100, "Callback", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
SetWindowCallback(@WinCallback()) ; activate the callback
Repeat
Select WaitWindowEvent()
Case #TaskbarCreated
; The task bar has been (re)created. Free the existing icons and create new ones here.
; Log a fault or whatever...
Debug "#TaskbarCreated"
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf