πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#138
From: CG
Date: Fri, 24 Nov 2000 00:00
43 lines
3004 bytes
"Jem Berkes" <jem@pc9.CutThis.org> a οΏ½crit dans le message news:
3A1DDF20.D1731E47@pc9.CutThis.org...
> Is the icon displayed in the system tray just the icon handle from the
> "Title TrayIconWindow" window class? I'm trying to figure out how to
> retrieve this icon.
>
> 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).

Chris.

>
> >     First, retrieve the Window which manages the callback of the tray.
(Use
> > Spy++, if you have no idea, it's often the "About box" displayed when
you
> > click on the trayicon). Then just reminds the title of this Window; we
> > called it "Title TrayIconWindow" in the sample below. Retrieve the value
of
> > the ID of the TrayIcon  (Use spy++...) called ID_TrayIcon in the sample
> > below...
> > Then retrieve the handle of the window from your application, before
killing
> > the application which creates the TrayIcon like that :
> > HwndTrayIconWnd = FindWindow (NULL, "Title TrayIconWindow");
> > Kill the application then...
> >
> > NOTIFYICONDATA nd;
> >
> > nd.cbSize = sizeof (nd);
> > nd.hwnd = HwndTrayIconWnd;
> > nd.uID = ID_TrayIcon;
> >
> > ShellNotify_Icon (NIM_DELETE, &nd);
Technical Details
Message-ID: <dDrT5.1136$CG2.3521654@nnrp1.proxad.net>
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>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1138df,d00bad325b1977a5
X-Google-Attributes: gid1138df,public
X-Google-Thread: 113dfb,d00bad325b1977a5
X-Google-Attributes: gid113dfb,public
X-Google-Thread: 1053e6,d00bad325b1977a5
X-Google-Attributes: gid1053e6,public
X-Google-Thread: 104d65,d00bad325b1977a5
X-Google-Attributes: gid104d65,public
X-Google-Thread: f5082,d00bad325b1977a5
X-Google-Attributes: gidf5082,public
From: "CG" <cgranottier@nospamseres.fr>
Subject: Re: How to Kill a Tray icon from an another application  ?
Date: 2000/11/24
Message-ID: <dDrT5.1136$CG2.3521654@nnrp1.proxad.net>
X-Deja-AN: 697357426
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>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp1.proxad.net 975062601 212.27.60.170 (Fri, 24 Nov 2000 11:43:21 MET)
Organization: Guest of ProXad - France
X-MSMail-Priority: Normal
NNTP-Posting-Date: Fri, 24 Nov 2000 11:43:21 MET
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