Notify Icon Vanishes From Tray

S

Stewart Berman

Windows XP Pro SP3 with all patches
VS 2005 with all patches

I have a long running application with a GUI foreground task and a BackgroundWorker task. It
includes a NotifyIcon that sits in the tray. The GUI removes itself from the taskbar during startup.
When the GUI is minimized it sets me.visible=false. The NotifyIcon can be used to restore the GUI.

The application was running for about two and a half days when I noticed that the NotifyIcon was
missing from the tray. The application itself was still running and writing trace messages. I was
able to restore the GUI with a little utility I have. The GUI was fine as was the BackgroundWorker
tast -- it was still updating a progress bar on the GUI.

I closed the application and restarted it and the NotifyIcon was back in the tray.

There isn't any code in the application that would remove the NotifyIcon from the tray.

The only reference to the visible property of the NotifyIcon is in the main form designer code in
the InitializeComponent section where it is set to true.

What could make the NotifyIcon disappear without affecting the rest of the application?
 
G

gillardg

on windows XP ( pretty sure that also on other Win OS )
make a right click on the notification area and you will see that there is a
setting
to hide inactives icons => just disable it
 
S

Stewart Berman

There is also a "<" to show the hidden icons and I used that to try and find it. The icon was
really gone not just hidden.
 
J

Jie Wang [MSFT]

Hi Stewart,

Could you provide more information on this issue?

Like when exactly the icon disappeared? Could it related to the
BackgroundWorker problem in your previous post?

Are there any code that uses the NotifyIcon component?

The component couldn't be unloaded without any reasons, but currently it is
hard to say why due to the lack of info.

Thanks,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Stewart Berman

Like when exactly the icon disappeared? Could it related to the
BackgroundWorker problem in your previous post?

No -- this was a separate execution of the application.

As I noted in the original message the BackgroundWorker task was still running -- it had not
aborted. The foreground GUI was minimized and invisible. There wasn't any error message on the
screen.

I have a little utility written in VB6 that walks all of the existing windows and lets me change
some attributes. (It was originally written to explore blending.) I used it to restore the GUI.
The GUI code makes itself visible when it is restored. The BackgroundWorker task was still running
and sending progress information to the GUI task.

I had no way to recreate the Notify Icon in the tray so I exited the application and then restarted
it which put the Notify Icon back in the tray.

The application was running overnight so I have no way of knowing when the Notify Icon vanished. The
events in it that were monitored (i.e. trace messages) where the Double Click and Right Click events
and there were no trace messages from these. There isn't any startup or shutdown event for the
Notify Icon.
 
J

Jie Wang [MSFT]

Okay, how about adding a temporary button to the UI, add code to this
button click event that simply access the NotifyIcon.Visible property or do
something else against the NotifyIcon?

Run the application until you the Icon is gone again. Then restore the UI,
press the button, see anything happens?

I've seen bugs related to NotifyIcon in earlier versions of .NET, but most
are fixed in service packs. And this is the first time I heard the
NotifyIcon just disappears. We need a constant repro of this issue so we
can proceed to find out the root cause.

Thanks,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Stewart Berman

Okay, how about adding a temporary button to the UI, add code to this
button click event that simply access the NotifyIcon.Visible property or do
something else against the NotifyIcon?

What's funny is that I added a left mouse button event in the NotifyIcon code to show the Window
State of the GUE when I was having problems with minimizing it and setting visible=false. Now I
need the same code in the GUI to show what is going on in the NotifyIcon.

Since the NotifyIcon should always be visible I'll add a couple of trace statements in the outer
loop of the BackgroundWorker task to log the NotifyIcon properties.
Run the application until you the Icon is gone again. Then restore the UI,
press the button, see anything happens?

I've seen bugs related to NotifyIcon in earlier versions of .NET, but most
are fixed in service packs. And this is the first time I heard the
NotifyIcon just disappears. We need a constant repro of this issue so we
can proceed to find out the root cause.

The problem is I've been running this for a few weeks -- each time for at least a day -- and this is
the only time the NotifyIcon vanished.

Someone pointed out that it could have been hidden but I press the arrow button to see hidden icons.
It is possible that this was a problem in XP's tray handling rather than a .Net problem.

I ran my VB6 utility while the NotifyIcon was in the tray and did not see (or could not identify it)
on the list of windows. Is it a real window or something the tray paints? If it is a real window
what, if anything, should be returned by GetWindowTextLength and GetWindowText?
 
J

Jie Wang [MSFT]

Is it a real window or something the tray paints?

It is not a real window in the notification area (AKA tray, but it should
not be called tray, see
http://blogs.msdn.com/oldnewthing/archive/2003/09/10/54831.aspx).

However, the NotifyIcon class itself has a internal NotifyIconNativeWindow
to recieve WM_* messsages from the notification area - just like in VB6,
you call Shell_NotifyIcon passing in a HWND and you need to subclass that
window to get the messages.

The NotifyIcon is just a wrapper for the Shell_NotifyIcon function.

Regards,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Stewart Berman

I don't want to subclass it -- I just want to be able to identify it when I walk all the windows in
the system. Again, what would, if anything, should be returned by GetWindowTextLength and
GetWindowText called against the NotifyIconNativeWindow?
 
J

Jie Wang [MSFT]

There is a little misunderstanding here. I didn't ask you to subclass it.
The subclass part I wrote about is how people make Shell_NotifyIcon work in
VB6.

Back to the troubleshooting part, you won't get anything against the
NotifyIconNativeWindow.

If you have source code and VS on that machine, the next time you saw the
icon disappearing, you can also attach the VS debugger to your process and
see what's going wrong in it.

Regards,

Jie Wang

Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Stewart Berman

If you have source code and VS on that machine, the next time you saw the
icon disappearing, you can also attach the VS debugger to your process and
see what's going wrong in it.

Will do -- thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top