Windows Tray Item -- Weird Phantom behaviour and its not even Halloween yet

I am using the TrayItem class ( for Windows 10 target and I am finding weird multiple phantom instances (icons) on the Windows tray. Why I call them phantom is that when you run your mouse over them all of the phantom icon’s go away real quick and the correct trayitem icon remains. It also doesn’t happen every time which is really weird.

App.Open Function:

#If TargetWindows Then
Tray = New AppTrayItem
Tray.Icon = vsRoundLogoWhiteBG2000
Tray.Tooltip = “VS v” + app.MajorVersion.ToString + “.” + app.MinorVersion.ToString + “(” + app.BugVersion.ToString + “)”

If Not Self.AddTrayItem(Tray) Then
Call Common.writeLog(System.LogLevelCritical, “VS App.TrayItem failed to instantiate”)
End If



#IF TargetWindows Then
Select Case cause
Case 100,101
Var trayMenu as New MenuItem
trayMenu.AddMenu(New MenuItem(“VS”))
trayMenu.AddMenu(New MenuItem(“About”))
trayMenu.AddMenu(New MenuItem(“Quit”))

Var result as New MenuItem
result = trayMenu.PopUp

If result <> NIl Then
  Select Case result.Text
  Case "VS"
  Case "About"
  Case "Quit"
  End Select
End If

End Select

Thanks in advance.

cant try the code right this sec
Tray is a global property on app or something similar so it doesnt go out of scope ?

Yes Tray as AppTrayItem in App. Thanks @npalardy!

This typically happens if the app crashes, or otherwise quits, without removing the icon.

Thanks Andrew,

It’s Weird as my app doesn’t quit and there always is one real icon trayItem. I also put break points on the open event and I never see if fire when the phantom stuff shows. Weird. I need to use more break points tonight but It surely doesn’t quit or crash.

But after thinking About what you posted earlier and I may not be closing the item tray out properly. That would explain the appearance of randomness. Thanks Andrew and ill let you know.

That was it @charonn0 - Thank you!! I wasnt properly removing the icon (tray) on close.

I appreciate it!

1 Like