It is currently Fri Feb 26, 2021 7:30 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: SysTrayIcon disappear
PostPosted: Sat Feb 20, 2021 11:34 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:17 pm
Posts: 380
Location: United Kingdom
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:
; 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


Top
 Profile  
Reply with quote  
 Post subject: Re: SysTrayIcon disappear
PostPosted: Tue Feb 23, 2021 5:02 am 
Offline
User
User

Joined: Sat Dec 22, 2018 9:15 pm
Posts: 21
Thanks, interesting code and it works here.

So there is no direct way to detect if the Icon is destroyed?

BarryG wrote:
IsSysTrayIcon() will only tell you if your icons were created or removed by your app, and NOT if they were destroyed by an external factor like a desktop reset.

Take this amended example from the manual, and run it. While it's running, kill "explorer.exe" and restart it, and then click the ButtonGadget() from the code. The debug output will show non-zero for both, falsely indicating that the systray icons are valid, when in reality they're clearly dead and gone. This is because the code never used RemoveSysTrayIcon() on them.

In other words, it's totally pointless to check IsSysTrayIcon() if your app never uses RemoveSysTrayIcon().

Thanks, but:
Balmung wrote:
Ok, i see, i was wrong. If you kill explorer.exe and start it new than my tools icon came not back. So issystrayicon() did not work on that. Is there a other way to test it? Because from all other software the icons are back.


Top
 Profile  
Reply with quote  
 Post subject: Re: SysTrayIcon disappear
PostPosted: Tue Feb 23, 2021 8:59 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1301
Balmung wrote:
Is there a other way to test it? Because from all other software the icons are back.

You do it the way Spikey showed above. It's similar to how I do it for my apps. I can post my own example if you want?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: mk-soft and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye