Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.30/5 (3 votes)
See more:
Hello, I have an app I'm working on that runs in the background and I have a NotifyIcon in the system tray, which I use to notify the user of some things. But now I came to a little problem.

I want to be able to always show the icon next to the system icons, i.e. Action centre, network, sound. And not hidden with other apps whereby you have to click the up arrow to show them.

If your not sure what I mean, there is this thing in control panel under Notification Area Icons which allows you to change what each icon can do, i.e. 'Show icon and notification', 'Hide icon and notifications' and 'Only show notification' <-- that's a Windows 7 example, I don't know how it would be in XP or Vista. But that is basically what I want to do. I want to programmatically set my application to 'Show icons and notifications'.

I know it's possible! I've seen it in action. A program named DropBox - once installed it automatically appears next to the clock and it's icon is always shown.

Here is an image example of how I want it to be: (The arrow shows my application)

http://i719.photobucket.com/albums/ww199/Pk_King_X11/NotifyIconExample.png

------------------------------------------------------------------

EDIT: Please goto: "Control Panel\All Control Panel Items\Notification Area Icons" (Windows 7)

^ You will see each icon has a behaviour, I want to set mine to 'Show icon and notifications' programmatically. I know it is possible... DropBox has done it.

EDIT 2:

OK, now I see how it works. Programs like DropBox and some Anti-Viruses basically change their icon's position in the tray... By changing it to 0 or 1 which ever is the first one, basically puts them right next to the clock, thus automatically changing the Notification Area Icons settings to 'Show icon and notifications', now that's pure genius...

But then comes a question. How could I achieve this?
Posted
Updated 22-Mar-18 22:24pm
v10
Comments
Sergey Alexandrovich Kryukov 28-Sep-12 15:55pm    
Where is it "hidden"? Doesn't System.Windows.Forms.NotifyIcon do what you want?
--SA
Rokas Gustys 28-Sep-12 16:39pm    
Yes, I am using the NotifyIcon control for this... And its hidden in the place where it hides inactive icons (like in windows XP). I want it to be 'active' and shown next to the up-facing arrow that you press to show other icons. That's where all other apps icons go by default. Please see image I added.
Sergey Alexandrovich Kryukov 28-Sep-12 17:23pm    
This is exactly how such applications look. For example:
http://www.codeproject.com/Articles/36468/WPF-NotifyIcon

--SA
Rokas Gustys 29-Sep-12 16:54pm    
It doesn't seem to do what I want though (in Win 7 at least). Please see my second edit.
Sergey Alexandrovich Kryukov 30-Sep-12 19:18pm    
I see what you mean now...
--SA

You don't have control over this in your app. It's based entirely on a "whoever gets there first, wins" basis.
 
Share this answer
 
Comments
Rokas Gustys 28-Sep-12 16:20pm    
No, you don't get what I mean...

If your on Windows 7, go into control panel and go to Notification Area Icons. You will see what I mean. All notification area icons can be adjusted to be shown all the time or not. I'm just trying to find a way to do it programmatically.

And as I said, if DropBox can do it, then it is possible. There must be some API or something.
Dave Kreskowiak 29-Sep-12 14:36pm    
It's Windows 7 and I know what you're trying to do. You still have no control over it. From MSDN:

Windows 7 has gone a step further by focusing the notification on its original purpose of being a notification source. Most icons are hidden by default in Windows 7, but can be promoted to the notification area manually, by the user. To keep users in control of their desktops, there is no way for your program to perform this promotion automatically. Windows still displays notifications for hidden icons by promoting them temporarily.

Also, read http://blogs.msdn.com/b/oldnewthing/archive/2010/12/15/10105142.aspx
Rokas Gustys 29-Sep-12 15:12pm    
Yes, I have realized that now. See my second edit...
Dave Kreskowiak 29-Sep-12 15:48pm    
Yeah, what part of "there is no way for your program to perform this" don't you understand??
Rokas Gustys 29-Sep-12 15:49pm    
Yes there is!!! DropBox and quite a few Anti-Virus programs did it so yes it is possible to do it!!!

Please don't bother replying if you don't know how...
There is no API[^] for it, sorry. Windows was designed this way on purpose.

However, I image the options are stored somewhere in the registry, so you may want to dig around there.
 
Share this answer
 
Comments
Rokas Gustys 28-Sep-12 16:57pm    
The only thing in the registry is to either show all hidden icons or hide them (default).

Please, if you don't know how then don't even bother. I know it's possible as I said DropBox has done it!!!
lewax00 28-Sep-12 19:12pm    
It didn't when I installed it to my machine. I think what happens is the first so many programs that add their icon there get marked that way, and any after that don't (I had a lot of programs in my tray already).
Rokas Gustys 29-Sep-12 16:55pm    
Are you running Windows 7?
lewax00 29-Sep-12 17:03pm    
Yup.
Dave Kreskowiak 28-Sep-12 20:07pm    
Dropbox does it on YOUR machine. It's not sitting over there on mine.
According to Microsoft, it is not possible to do this.

Quote:
There is no way for applications to programmatically always show themselves top level on the system tray either on first install or at any time during runtime. This is one of several changes we’ve made in Windows 7 in an effort to produce a cleaner, quieter desktop that is in the user’s control to customize the top level with their favorite applications and icons.


One thing to note is that Windows seems to remember the settings you choose when you uninstall an application, and then reinstall it. Is it possible that this is what happened?

When I installed DropBox on my Win8 desktop and my Win7 laptop, the icon was hidden until I manually went in and set it to "Show icon and notifications".


What would be really nice is if Windows detected this icon when DropBox (or any app that has an icon) was first installed, and prompted the user to Always hide, or Show Notifications, or Always Show. That would probably go against their "effort to produce a cleaner, quiter desktop" though, so it probably wouldn't happen.
 
Share this answer
 
v3
For those who keep telling that it's impossible... Here's the C# code: http://hianz.wordpress.com/2012/07/13/modify-windows-7-notification-area/[^]
The downside of this code is that you need to kill explorer.exe and rerun it in order for the changes to take effect and not overridden in next windows startup

@Rokas, I am at the same side that you are. Dropbox icon is always shown in tray icon no matter on what system I install it. I even did a fresh install of windows 7 and then I installed Dropbox, it never changed to be hidden and stayed in notification area, I looked at its notification settings and it was set to "Show icon and Notifications".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900