🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#143
From: Aurelian Coasan [MS]
Date: Fri, 17 Nov 2000 00:00
73 lines
3612 bytes
Hi!

an interesting question; so i took a look at it.
in my tests neither adding and deleting a new status area icon nor
invalidating the status area window worked.
so i came up with the following solution. (it seems a little unprecise, but
i'll append also one of the attempts i made, to show that the "normal",
more professional trials didn't work.) the one i show after the solution,
which uses TB_GETITEMRECT doesn't work (the message returns TRUE, but the
contents of the RECT are not valid, hence this not very precise variant i
came up with eventually - but try it, i tested it on win2k and didn't
encounter problems, but who knows..., i don't guarantee anything - it could
hide surprises):
=========================================
solution:

HWND hwndTaskBar, hwndTrayWnd, hwndTrayToolBar;
  BOOL res;
 hwndTaskBar  = FindWindowEx (NULL, NULL, "Shell_TrayWnd", NULL);
 hwndTrayWnd = FindWindowEx (hwndTaskBar , NULL, "TrayNotifyWnd", NULL);
 hwndTrayToolBar = FindWindowEx(hwndTrayWnd, NULL, "ToolbarWindow32", NULL);
 RECT rTrayToolBar;
 ::GetClientRect(hwndTrayToolBar, &rTrayToolBar);
 for (WORD x = 0; x < rTrayToolBar.right ; x += 8)
  for (WORD y = 0; y < rTrayToolBar.bottom ; y +=8)
   ::SendMessage(hwndTrayToolBar , WM_MOUSEMOVE, 0,
    MAKELPARAM(x,y) );
==========================================
this doesn't work (at least on win2k not):
LONG lNrButtons = (LONG)::SendMessage(hwndTrayToolBar, TB_BUTTONCOUNT,
  0, 0);
 RECT rButton;
 for (LONG i = 0; i < lNrButtons; i++)
 {
  res = ::SendMessage(hwndTrayToolBar,
   TB_GETITEMRECT,
   (WPARAM) i,
   (LPARAM) &rButton);
  ::SendMessage(hwndTrayToolBar,
   WM_MOUSEMOVE,
   0,
   MAKELPARAM
    (
     (WORD) ((rButton.left + rButton.right) /2),
     (WORD) ((rButton.top + rButton.bottom ) / 2)
    )
   );
 }

hth,
-aurelian

"CG" <cgranottier@nospamseres.fr> schrieb im Newsbeitrag
news:FU8R5.763$%o6.2878648@nnrp3.proxad.net...
> In my program, I make a system kill of an application that have an icon
tray
> in the traybar...
> But the problem is that the icon isn't kill properly by the killed
> application to the task icon remains here.
> The only way to delete the tray icon is to move the mouse over the tray
> icon, but I'd like to di it in my programm after I kill the application.
> I try something like that :
>
> hwndTaskBar  = FindWindowEx (NULL, NULL, "Shell_TrayWnd", NULL);
> hwndTrayWnd = FindWindowEx (hwndTaskBar , NULL, "TrayNotifyWnd", NULL);
>
> and then SendMEssage (hwndTrayWnd , WM_PAINT, 0, 0);
>
> but it doesn't work.
> Any idea ???
> Chris.
>
>
Technical Details
Message-ID: <enTSzhLUAHA.250@cppssbbsa02.microsoft.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <FU8R5.763$%o6.2878648@nnrp3.proxad.net>

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: 113dfb,d00bad325b1977a5
X-Google-Attributes: gid113dfb,public
X-Google-Thread: f5082,d00bad325b1977a5
X-Google-Attributes: gidf5082,public
X-Google-Thread: 1053e6,d00bad325b1977a5
X-Google-Attributes: gid1053e6,public
X-Google-Thread: 104d65,d00bad325b1977a5
X-Google-Attributes: gid104d65,public
From: "Aurelian Coasan [MS]" <mtsis@microsoft.com>
Subject: Re: How to Kill a Tray icon from an another application  ?
Date: 2000/11/17
Message-ID: <enTSzhLUAHA.250@cppssbbsa02.microsoft.com>
X-Deja-AN: 694802033
References: <FU8R5.763$%o6.2878648@nnrp3.proxad.net>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-MSMail-Priority: Normal
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