System tray icon does not always show when starting app when Windows starts

System tray icon does not always show when starting app when Windows starts

Post by Patrick Du » Thu, 03 May 2007 01:20:03


I am using VS2005 (vb) and I have a program that starts when Windows boots
up. Occasionally the icon that should appear in the system tray does not
show up. The program is still running in memory but the tray icon is not
there. If I start the program after Windows has booted up the icon shows
every time. I am assuming that the reason is due to the icon being created
before the system tray is loaded/running. I have used a timer with "dim
notifyicon1 as new notifyicon" every few seconds and that works but I am
afraid I am eating up memory doing that or is that "ok" to do?

Is there any way to detect if the system tray is not running so I can delay
the creation of the tray icon until it is?
 
 
 

System tray icon does not always show when starting app when Windows starts

Post by Newbie Cod » Thu, 03 May 2007 11:08:05

Patrick,

You can handle this many ways, but here are a couple:

1) Check to see if the process is already running
2) Embed the icon in the executable

By continuing to create a new NotifyIcon object you are indeed using memory

How are you starting this application?

Hopefully you are using a module with sub main, creating an instance of your
form & running it from there. If not, you should because then you can hide
the form, display the tray icon like you want. I have a few VB.NET
applications running on startup like you wish without problems doing it the
sub main way

--
Newbie Coder
(It's just a name)


created
delay

 
 
 

System tray icon does not always show when starting app when Windows starts

Post by Patrick Du » Thu, 03 May 2007 21:27:21


The icon is embedded in the main program and it is called from an instance
in sub main. The problem is *sometimes* the icon will not show up if the
program is set to start when Windows boots up. The problem is rare but
nonetheless still happens on occassion. The question is how do I determine
that the system tray has started so I can wait to initialize the icon at
that point. I already know to look for a process but so far I cannot tell
what process indicates the system tray is up and running.

I also need to determine if Explorer crashes and the tray icons need to be
refreshed. How can you tell that has happened and you need to re-establish
the tray icon?
 
 
 

System tray icon does not always show when starting app when Windows starts

Post by G Himang » Sun, 06 May 2007 20:45:20

hen the taskbar is recreated, the system sends the registered window
message "TaskbarCreated" whose value you can get using
RegisterWindowMessage("TaskbarCreated");

You will need to catch this message and reinsert the tray icon

If you dont mind a commercial solution, you can try our ShellNotifyIcon
component at http://www.ssware.com/shlobj/shlobj.htm

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------





"Patrick Dugan" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...