🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4876

Re: Refresh The System Tray

#4876
From: Remy Lebeau (TeamB)
Date: Mon, 21 Nov 2005 18:36
50 lines
2961 bytes
"AJ" <adam_bouchard@sbcglobal.net> wrote in message
news:438201d2@newsgroups.borland.com...

> When my application ends it, the icon is still in the
> system tray until the mouse pointer is pointed on the
> system tray.

How exactly are you terminating the application?  It sounds like you are not
allowing it to terminate gracefully and clean up after itself.

> I have tried to investigate the Shell_NotifyIcon function,
> but since the application is not mine, I do not know the
> taskbar ID of the application.

You cannot use Shell_NotifyIcon() to control other application's icons, only
your own.

> Is there any other way to do a general refresh of the system tray
> (similar to what happens when the mouse pointer is on the system tray)
> programatically?

> In searching the web, Visual C++ has a utility call Spy++ that can
> imspect the icons in the system tray and return the taksbar ID.

Spy++ is not part of VC++ specifically.  It is a standalone utility that you
can download from Microsoft separately.  It does not, however, have a
specific option of inspecting System Tray icons.  It can, however, intercept
and peek into any message for any window.  So, you can intercept the
WM_COPYDATA message that Shell_NotifyIcon() sends to the System Tray.
Shell_NotifyIcon() puts a copy of the NOTIFYICONDATA structure into the
WM_COPYDATA message (amongst sone other things).  You can also intercept the
WM_COMMAND messages that are sent when the mouse is moved over the icons.
The wID member of the message will be the icon ID.

> Then the Shell_NotifyIcon function can be used.

It is quite not that simple.  Shell_NotifyIcon() also requires an HWND.  It
is the combination of HWND and ID that uniquely identifies each icon in the
System Tray.  You would have to know which HWND is also being passed with
the ID.

> Does C++ Builder have any utility like this

BCB ships with WinSight, which works similarly to Spy++.  I prefer Spy++
myself, though, because it works better than WinSight.  WinSight is a memory
hog and tends to crash a lot.


Gambit
Technical Details
Message-ID: <43821387$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <438201d2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8ad97936ff76c516
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <438201d2@newsgroups.borland.com>
Subject: Re: Refresh The System Tray
Date: Mon, 21 Nov 2005 10:36:34 -0800
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <43821387$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1132598151 68.69.17.41 (21 Nov 2005 10:35:51 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail