🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools.mfc
Article #135

Re: How to Kill a Tray icon from an another application ?

#135
From: Dirk Fieldhouse
Date: Sun, 26 Nov 2000 00:00
39 lines
3416 bytes
In article <3A1E75F2.158324F9@pc9.CutThis.org>, Jem Berkes 
(jem@pc9.CutThis.org) says...

>> > How exactly are you retrieving ID_TrayIcon? According to MSDN,
>> > NOTIFYICONDATA.uID is "Application-defined identifier of the taskbar
>> > icon"
>> Yes it is, but you can use Spy++ to retrieve it's value. With Spy++ Scan
>> messages sent to the Window which has created TrayIcon ( "Title
>> TrayIconWindow" in my sample application), then move your mouse on the
>> TrayIcon for which you want to retrieve the ID, then you'will see in the
>> scan Messages window of Spy++ a message like
>> "WM_COMMAND wNotifyCode:0000 wID:130 hwndCtl:00000200"
>> wID is the value of the TrayIcon (130 in my sample).

>Thanks... that's really neat! Once you have the icon ID is there any way
>to "read" the icon? I mean get its HICON or something, for copying. I've
>tried getting the Rect for TrayNotifyWnd and then scanning within there
>using ChildWindowFromPointEx but the icons don't appear to be "child
>windows" or anything. And I can't find any docs that explain how those
>icons are stored. Any ideas?

Of course the application could choose a different ID for its tray icon every 
time it runs, but applications normally use a constant value.

It may be helpful to consider that the structure given by the application to 
the tray API (Shell_NotifyIcon()) is passed in a WM_COPYDATA message to the 
shell window. Obviously you could hook that message and copy the icon, if 
present.

Equally obviously this is not part of the Win32 API and could easily change 
(for all I know it may already have changed in W2k or Whistler) in some future 
shell32.dll.

-- 
Dirk Fieldhouse                 Logica UK Limited
fieldhouse@logica.com           75 Hampstead Road
c=gb;a=attmail;p=logica;        London NW1 2PL
o=LOGICA;ou1=UK;s=fieldhouse    UK
+44 (20) 7637 9111
Technical Details
Message-ID: <975246544.696508@ernani.logica.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <FU8R5.763$%o6.2878648@nnrp3.proxad.net> <enTSzhLUAHA.250@cppssbbsa02.microsoft.com> <8v6T5.648$NT.1224749@nnrp2.proxad.net> <3A1DDF20.D1731E47@pc9.CutThis.org> <dDrT5.1136$CG2.3521654@nnrp1.proxad.net> <3A1E75F2.158324F9@pc9.CutThis.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1138df,d00bad325b1977a5
X-Google-Attributes: gid1138df,public
X-Google-Thread: 1053e6,d00bad325b1977a5
X-Google-Attributes: gid1053e6,public
X-Google-Thread: 113dfb,d00bad325b1977a5
X-Google-Attributes: gid113dfb,public
X-Google-Thread: f5082,d00bad325b1977a5
X-Google-Attributes: gidf5082,public
X-Google-Thread: 104d65,d00bad325b1977a5
X-Google-Attributes: gid104d65,public
From: Dirk Fieldhouse <fieldhouse@logica.com>
Subject: Re: How to Kill a Tray icon from an another application  ?
Date: 2000/11/26
Message-ID: <975246544.696508@ernani.logica.co.uk>
X-Deja-AN: 697875991
Cache-Post-Path: ernani.logica.co.uk!unknown@158.234.39.232
References: <FU8R5.763$%o6.2878648@nnrp3.proxad.net> <enTSzhLUAHA.250@cppssbbsa02.microsoft.com> <8v6T5.648$NT.1224749@nnrp2.proxad.net> <3A1DDF20.D1731E47@pc9.CutThis.org> <dDrT5.1136$CG2.3521654@nnrp1.proxad.net> <3A1E75F2.158324F9@pc9.CutThis.org>
Followup-To: comp.os.ms-windows.programmer.win32
Content-Type: Text/Plain; charset=US-ASCII
X-Complaints-To: abuse@uk.uu.net
X-Trace: soap.pipex.net 975246544 10470 193.123.204.68 (26 Nov 2000 13:49:04 GMT)
Organization: Logica plc (for whom I do not speak)
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Mime-Version: 1.0
NNTP-Posting-Date: 26 Nov 2000 13:49:04 GMT
Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.programmer.win32,fr.comp.os.ms-windows.programmation,microsoft.public.fr.vc,microsoft.public.vc.mfc