Windows System Tray Application - wpf

I created a WPF window with system tray icon via NotifyIcon. When I click the icon in the system tray, the WPF application pops up and is shown on the screen.
But this solution does not fit my needs. I want the solution to be opened the same way the volumn, network center, security center, etc. is opened on system tray icon single click (just a little tiny box on top of the taskbar which can neither be moved nor has a close button in the upper right corner).
Can anyone give me a hint?

Does WindowStyle.None fit your needs (Can be set in the WindowStyle Property of your Window)?

Related

How to show a WPF window above a TaskBar icon?

In Google's Chrome App Launcher for Windows, does anyone know how they managed to show the window such that it's centered above the application's icon in the TaskBar? Any kind of solution for C#/.NET would be fine (p/invoke, etc.).
I've searched high and low and there are solutions for the System Tray based on identifying the screen rect of a notify icon, but I have not found one for the TaskBar (except one approach that is based on a screen capture, but it's too fragile for production applications).
Thanks!
-Tom B.
Thanks to NETscape's hint, I found that the way that the Chrome App Launcher makes it look like the window is appearing over the TaskBar icon is by checking the mouse position immediately after starting up, and if the mouse is in the TaskBar area then it shows the window directly above the TaskBar and horizontally centered over the mouse.
You can test this by moving the mouse left or right immediately after clicking the icon, in which cases the window appears to the left or right of the TaskBar icon. If you move the mouse outside the TaskBar area right after clicking it (or launch the app from a Desktop icon) then the window is just anchored to the lower-left corner of the screen.

How to show VB application ONLY in system tray

Is it possible that we can show application only in system tray(the tray at bottom right of screen) instead of , as normally application opens in bottom bar ? If yes then how can we do it in Visual Basic 2010 .
There is a showInTaskbar property you can set to false on your windows form. Moreover you can set Visible to false.
In your Designer you can add a notifyIcon to your form, this is the typical tray icon you are searching for.

Determining location of tray icon

My application is designed to sit in the system tray and behave similarly to the Network/Volume/Power/Action Centre tray items in Windows 7 (and the equivalent items in Windows Vista). That is, it becomes visible when the tray icon is clicked, and becomes hidden when focus is lost.
The application is written in WPF, but I am currently using NotifyIcon from WinForms for the tray icon.
I would like to know if anyone has any suggestions as to how I might determine the position (i.e. screen coordinates) of my application's tray icon. The default Windows Vista/7 tray items have some way of doing this, since the pop-out windows are centre-aligned above the relevant tray icon.
In Vista this wasn't much of an issue: I had the application permanently set to the bottom-right corner, and this looked fine (though there was no logic included for cases when the taskbar wasn't placed at the bottom of the screen). However, in Windows 7 my application ends up obscuring the new system tray pop-out box, rather than hovering above it like the volume controls, etc., do.
The best solution I've seen in my searches so far is to handle the mouse-up event on the NotifyIcon and use the mouse coordinates to determine the position of the icon. I think I'll end up using this method if unless someone has a better idea, though it's not ideal as the position will vary slightly depending on where within the icon the user clicks.
Windows 7 and higher expose the Shell_NotifyIconGetRect() function, which returns the screen coordinates of the icon's bounding rectangle.
You'll need to provide it the notify icon GUID, though, and I don't know if you can access that property through the managed NotifyIcon class.
Further to this, I've written about a method to find the location of a notify icon when the Shell_NotifyIconGetRect function is not available: http://blog.quppa.net/2010/12/28/windows-7-style-notification-area-applications-in-wpf-part-6-notify-icon-position-pre-windows-7/

Tray Icons Keep On Popping Up

I have a WinForm program that checks a database for changes, and if there are any, it will open another WinForm telling the user what is happening (the popup WinForm has some special functionality making a MessageBox insufficient for this task). Each time one of these popup WinForms shows up, a new icon shows up in the system tray and does not go away even if you hover over it (this isn't a tray refresh issue).
What I'm wondering is how to get the popup WinForm to display no tray icon at all.
You might be doing something like 'new NotifyIcon' in the wrong places (like the constructor of your popup-form). It gets created, but if you never call NotifyIcon.Dispose() it will stay until you stop your program and hover you mouse over the icon.
Another cause might be that you have added the NotifyIcon as a component to the popup-form in the designer.

Prevent WPF Window From Minimizing (Winkey + D, mostly)

I have a window which is supposed to act like a Windows Vista(+) gadget; its supposed to stay on the desktop, not to appear on taskbar and the alt+tab menu, but most importantly, not to get minimized.
Here is its header:
As its style is set to None, it has no control buttons (minimize, close, etc...) but it still can be minimized using the "Show Desktop" feature and the Winkey+D combination.
How can I prevent that from happening?
Thanks!
"Show Desktop" does more than just minimize windows - after minimizing all the windows it can, it then brings the desktop window to the top of the z-order. Raymond Chen has a good explanation of this.
You could mark your window as "always on top" but then it would appear on top of every window. I can't think of any other way of preventing Show Desktop from hiding your window. A quick experiment with Windows Sidebar shows that it is also minimized on Show Desktop unless you set the "Sidebar is always on top of other windows".

Resources