system tray / taskbar icons on startup program

system tray / taskbar icons on startup program

Post by nospa » Sun, 20 Mar 2005 00:45:03


Hello,

I've developed numerous utility programs that can be configured to run
automatically on startup and place themselves in an icon on the taskbar. My code
to do this looks something like the following:

// setup the struct
NotIcon.hIcon = Hicon; // icon was loaded from resources
NotIcon.cbSize = sizeof(NotIcon);
NotIcon.hWnd = MainForm->Handle;
NotIcon.uID = 0;
NotIcon.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
NotIcon.uCallbackMessage = ActivityMessage;
strcpy(NotIcon.szTip, Tip);

// add the icon to the taskbar
Shell_NotifyIcon(NIM_ADD,&NotIcon);

// Hide the main form
MainForm->Hide();

The problem I'm having is that each utility, when run by the user "manually" can
place itself in a taskbar icon fine, but.... when all of the utilities are
configured to autostart when windows, weird things are happening with the icons.
Most notably, I've noticed two problems:

1) Sometimes (randomly) the programs icon will not appear in the tray, even
though the program is visible as a process in the task manager.

2) I've had one instance of a "blank" icon showing up, which when right-clicked
is a duplicate of the "windows messenger" icon. I'm assuming this "blank" icon
is some broken version of one of my icons that was supposed to be there.

My question is -- has anyone experienced this problem before? Is there any
reasons why creating these icons at startup time would be causing a problem?

Thanks!
 
 
 

system tray / taskbar icons on startup program

Post by nospa » Mon, 21 Mar 2005 13:58:46

ello Sev,

Thanks for the reply -- I started checking the return code of shell_notifyicon
and I've found that occasionally it is returning FALSE. The problem appears to
be random.

If I were to hazard a guess, I would say that during startup, sometimes my
utilities are getting created before explorer and the taskbar are ready (thus
leading to the failure messages...)

I haven't tried responding to the "TaskbarRestart" message (that is new to
me...) so I'm hoping that will fix the problem.

Scott

In article < XXXX@XXXXX.COM >, Severian says...