Duncan
Duncan

Reputation: 858

Tray NotifyIcon missing if application starts with system

I have a C# (VS 2012 Express) targeting .NET framework 2.0 which uses the NotifyIcon component to create a tray icon.

There is a shortcut to the application in the users Start Menu\Startup folder which results in the icon appearing in the tray when windows starts, most of time.

In some situations however, the executable launches on system startup but the icon is missing from the tray. I don't a have a set of reliable steps to reproduce this issue however.

From reading this article, it looks like I should be listening to the shell started event and re-drawing my tray icon, however I'm unsure how to go about doing this, as .NET is managing the low level calls for me: http://msdn.microsoft.com/en-us/library/windows/desktop/cc144179(v=vs.85).aspx

Any pointers would be greatly appreciated. Thanks!

Update: This problem only appears to happen when I have setup Windows to auto-logon to the default user account. If I manually logoff and then logon again my icon appears correctly.

Update: It appears that if I manually close and restart Explorer.exe, the icon is correctly redrawn.

Upvotes: 1

Views: 1194

Answers (1)

Duncan
Duncan

Reputation: 858

I solved this problem be toggling the visibility of the NotifyIcon component (from false to true) at the end of my form constructor (after calls to InitializeComponents).

Upvotes: 2

Related Questions