🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to remove dead system tray icons

#861
From: Dennis Jones
Date: Tue, 11 Dec 2007 07:24
45 lines
2649 bytes
"nicolasr" <nicolasrREMOVETHISSPAMBLOCKER@gmx.net> wrote in message 
news:475e00d0$1@newsgroups.borland.com...
> Hi all,
>
> I have a third party application (app1) that I need to automate.
> My controller app (app2) starts app1 and watches
> at certain intervals whether app1 is still alive.
> Every now and then app1 crashes, needs to
> automatically be terminated and restarted.
> (Unfortunately I don't have source code for app1
> to correct the actual problem....)
>
> This works as expected except for the fact that
> app1 has a tray icon and after app1 has been
> terminated and restarted several times the tray
> area expands over the entire task bar and
> displays dead tray icons of app1 that would
> disappear if I moved over them with the mouse.
> Unfortunately nobody sits in front of the PC and all
> this needs to be automated. So app2 should be able
> to remove those dead icons.
>
> I found some code like:
>
> HWND hTaskbar = FindWindow("Shell_TrayWnd", NULL);
> HWND hSysTray = FindWindowEx(hTaskbar, 0, "TrayNotifyWnd", NULL);
> RECT rect;
> GetWindowRect(hSysTray, &rect);
>
> that then uses mouse_event() to simulate a user moving the mouse
> over the system tray. While this works on my XP machine with one dead icon
> it does not work reliably on the business W2K machine with other things 
> running
> concurrently.
>
> Does anyone have any ideas how to do this?
>
> How about sending mouse messages directly to the sys tray window?
> Or any other way to force explorer to update the system tray?

I've posted a demo utility in the attachments group.  Try it out and see if 
it does what you want.

- Dennis 
Technical Details
Message-ID: <475e3b2d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <475e00d0$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5d96c60b60120dfe
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Dennis Jones" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <475e00d0$1@newsgroups.borland.com>
Subject: Re: How to remove dead system tray icons
Date: Mon, 10 Dec 2007 23:24:31 -0800
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 71.245.109.58
Message-ID: <475e3b2d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1197357869 71.245.109.58 (10 Dec 2007 23:24:29 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail