Article View: borland.public.cppbuilder.nativeapi
Article #688Re: Multiple Shell_NotifyIcon calls
From: Kris
Date: Sat, 23 Feb 2008 14:26
Date: Sat, 23 Feb 2008 14:26
59 lines
3274 bytes
3274 bytes
Remy Lebeau (TeamB) wrote:
> Why are you creating the icon so early to begin with?
Well, I assumed that the best time to create the icon is when my
application starts.
I suppose I could use a timer and wait until a few seconds after
initializing my app before actually creating the system tray icon. And
probably this will reduce, if not eliminate, my problem. But I would
have to pick an arbitrary number for the delay and I'm unsure what value
to pick. Should I wait 3 seconds, or maybe 10 seconds just to be sure?
Furthermore, when the user manually starts the application (instead of
during Windows start-up), they expect the system tray icon to appear
immediately).
So, perhaps it still would be best attempt to create the icon asap
during startup and then retry periodically (e.g. every second) until
NIM_ADD actually succeeds ?
This is where I attempt to create my icon during startup:
__fastcall TActivityMonitorServer::TActivityMonitorServer
(TComponent* Owner): TForm(Owner)
{
DEBUG("Activity Monitor Server %s started.",SERVER_VERSION);
SetTrayIcon(NIM_ADD,BALLOON_OFF,"RES_ICON_SERVER_WARNING");
...
}
> Are you setting up your message handler before "TaskbarCreated" is actually
> broadcasted?
I'm setting it up as soon as possible (during WM_CREATE) but since
NIM_ADD sometimes fails without subsequently ever receiving a
TaskbarCreated message, I'm guessing that something else is causing my
NIM_ADD to fail. The actual TaskbarCreated message handler is working
just fine, as can be confirmed when I simulate a shell crash (by
terminating and restarting explorer.exe)
void __fastcall TActivityMonitorServer::WndProc(TMessage& Message)
{
static UINT WM_TASKBARCREATED;
switch (Message.Msg)
{
case WM_CREATE:
WM_TASKBARCREATED=::RegisterWindowMessage(TEXT("TaskbarCreated"));
break;
default:
if (Message.Msg==WM_TASKBARCREATED)
{
// re-create the system tray icon
SetTrayIcon(NIM_ADD,BALLOON_OFF,"RES_ICON_SERVER_WARNING");
}
TForm::WndProc(Message);
}
Kris
Technical Details
Message-ID:
<47c02cfe$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<47B85E8F.6040508@ks.com> <47bb1415$1@newsgroups.borland.com> <47bc8219$1@newsgroups.borland.com> <47bc8d05@newsgroups.borland.com> <47bf5bd8$1@newsgroups.borland.com> <47bf6cce$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fd4854ec85a82474 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 23 Feb 2008 15:26:18 +0100 From: Kris <ks@ks.com> User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Multiple Shell_NotifyIcon calls References: <47B85E8F.6040508@ks.com> <47bb1415$1@newsgroups.borland.com> <47bc8219$1@newsgroups.borland.com> <47bc8d05@newsgroups.borland.com> <47bf5bd8$1@newsgroups.borland.com> <47bf6cce$1@newsgroups.borland.com> In-Reply-To: <47bf6cce$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 83.101.2.208 Message-ID: <47c02cfe$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1203776766 83.101.2.208 (23 Feb 2008 06:26:06 -0700) Lines: 59 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail