3
votes

can some one show me how to hide/show tray icons of other applications/processes using my application,i want to hide the ''connected to internet''icon(those two computers that turn blue when data is sent/recieved/both) from my app
edit: i can hide system clock using this snippet taken from http://scalabium.com/faq/dct0147.htm

ShowWindow(FindWindowEx(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'TrayNotifyWnd', nil), 0, 'TrayClockWClass', nil), SW_HIDE);

i guess i can use this code to hide ''internect connection icon''(by the way what is that icon called?) as well by replacing TrayClockWClass but by which class? i have tried to find class name using this tool called windowse but with no luck
edit2: i can hide those icons in windows by leftclicking 'tray window' then selecting properties and on properties windows clicking 'customize' button then changing icons property from 'hide when inactive' to 'always hide' can i do this in delphi or even better can i hide/show(completely) that icon whenever i want(using delphi)

3
Why would you want to do this? And why not work out what the control system is for hiding/showing that the tray uses (presumably in the registry), instead of messing with people's computers. Interfering with such things is going to cause people hassle. The networking icons are controlled by the control panel, so find the registry option that turns them off. Job done. - mj2008
i am not gonna mess with other people computer i am writing a personal program ,see edit2 doing it via registry i will have to restart my computer everytime? i want to hide/show with a buttonclick on my program with speed - Omair Iqbal
The Internet connection icon can be hidden by double clicking the tray icon, choose properties, and uncheck the "Show icon in notification area when connected" box. - Gerry Coll
@gerry: yes but now how do i bring it back? and can it be automated using anything programming language, setting, batch program script? basically what i am trying to program is something that will save taskbar space ,and more taskbar tray icons will make my taskbar space conjested,i open lots of ie windows that occupy taskbar space and i need to hide and bring back tray icons when i want thats why i ask - Omair Iqbal
@gerry : also automation is not important but it would be nice if you tell me,but please do tell me how do i bring it back its hidden and there should be something like hotkey or something to bring it back - Omair Iqbal

3 Answers

4
votes

The API does not expose access to other apps' icons. The only option is to subclass the system tray itself to intercept the window messages that Shell_NotifyIcon() sends to it so you can keep track of which HWNDs are registering which icon IDs.

3
votes

The clock example you cited works, because, although the clock icon is in the same area as the notification tray, it is not actually the same window but a separate window in itself. You can't hide a single icon using the same method because they are all treated as a whole.

You can hide the entire notification tray, though:

ShowWindow(FindWindowEx(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'TrayNotifyWnd', nil), 0, 'SysPager', nil), SW_HIDE);
0
votes

If you're in charge of the computer you're running on, then you just right click the icon and disable it manually. Presumably this writes some settings in registry (use procmon to find out), so you can automate it through Active Directory.

If you're not in charge, meaning it's not yours and just some random computer, and your app voluntarily decides to go ahead and hide icons it doesn't like, then no, there's no API to do that, and screw you for even trying. It's up to user to decide when he wants to hide the icon, not to your super cool program.