How to add ONLY system tray icon to application? - c#

I am developing an application that will be running behind the scenes in Windows and would like to put an icon in the system tray for troubleshooting purposes (simple way for users to tell if the app is running). There is no other UI for the application, and the icon does not need to have any functionality as of right now.
All of the solutions I have found as of yet involve creating a form. I am wondering if there is a way to simply add a class to my current C# code that allows me to control the icon, rather than doing the whole 'make a form, set it to be invisible....' nonsense that seems to be the popular suggestion on the forums. Something along the lines of the way that UI control is done in say, Swing for Java. I would really appreciate any ideas!

You can do it with a custom ApplicationContext. Google reveals first this tutorial on how to achieve it.
Or you can alter your main Program file not to show any form at all:
Application.Run(); //remove the Form oject from this call

From whatever project you use, why not just create an instance of the NotifyIcon class and use it to display the icon in the system tray?

For Windows Forms:
Form.ShowInTaskbar to show/hide in the taskbar
and use a NotifyIcon to show in the tray

Related

How to create a window within a UWP app to enter in detail/properties information

So I'm sure there's an easy way to do this but I don't know the exact terminology for what I'm wanting.
Essentially in my C# xaml uwp app I have a couple objects that need to have details added to them, kind of like file properties. I have a button that I would like to open up another window (still part of the app), just to enter in the properties. I just don't know the terminology to look up what this window would be called or find documentation for it. So the exact same as when you're in a file browser and you open the properties of a file; it opens in a little extra window that you can drag around.
I don't want to be able to use the main window while the properties window is open, and of course they need to be able to transfer data between one another.
In my previous apps I've simply made a grid that appears over everything else in the middle of the app and shaded the outer area. A workaround as I didn't know how to do this.
Can anyone help me out?
Maybe you can use Dialog refer to https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/dialogs-and-flyouts/dialogs.
Dialog controls are modal UI overlays that provide contextual app information. They block interactions with the app window until being explicitly dismissed. They often request some kind of action from the user.

What "growl" type notification windows are available for WPF (windows that appear and fade after X seconds)?

I wanted to know if there are any good "growl" type notification windows available as open source or guided tutorials for WPF applications. I'm looking for a window that can appear when users save for example, notifying them that the save was successful and then disappears after X seconds (with a fade out) without the user needing to take the explicit action to close the notification window. This way for messages/notifications that require no confirmation, like the example, the user would not have to click "OK" to make the messagebox or dialog close.
This link could help you:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
It is a Pure WPF implementation of the NotifyIcon class from WinForms and supports almost everything normal WPF controls do :)
Cheers
Why don't you use GrowlForWindows?
You can use C# or VB.

How to Detect Right Click on the Taskbar

I've got a Windows Forms application in C# that starts off with a loading dialog. As expected, a button for the app shows up in the Windows taskbar.
I would like to detect right-clicks that might be done to that button.
Ultimately, I hope to disable the right-click or simply have the loading dialog regain focus. I've seen that some people use custom libraries and packages (interop, for example) to achieve some Win32 functionality, but I'd personally like to avoid this. Is it impossible to do without such libraries/packages?
How about just not showing the form in the taskbar by setting Form.ShowInTaskbar to false?

Application in the Taskbar

Can you give me an example on how to put my application form in the taskbar?
like Windows media player or Window search when minimize.
What you are looking for is creating an Application Desktop Toolbar (also known as AppBar). The main function you use to register your application window as an AppBar is SHAppBarMessage.
To get you started, you can look at this old appbar example with C++. If you want to do it in C#, there's a thread that discusses some details on how to do it in WPF. I am not aware of examples of how to do it with WinForms, but a quick search on the web should bring something.
Update: Actually, if you want a toolbar that sits on the taskbar, you need to implement a Deskband. Here's a sample DeskBand in C++ and here's a DeskBand in C#.
That's what happens when you don't touch a topic in a while. :-)
What this is really called is the 'System Tray' You want your app to have an icon in the windows system tray. Many languages provide this functionality.
Here are a few links:
http://www.codeguru.com/Cpp/COM-Tech/shell/icons/article.php/c1335
http://www.codeproject.com/KB/shell/systemtray.aspx

Opening an application inside a form - C# or VB.NET

I am writing an application and I would like to be able to display another application inside it. (Think like a windows form with a small box, or a tab that is displaying a totally seperate application.)
Is that something that can be done? If so, can anyone give some direction on how to go about doing it?
I am looking for something in the C# or VB.NET world.
THANKS!
You need a hWnd (handle) of window from another application.
Then you need a hWnd of container control in you application (System.Windows.Forms.Control.Handle property).
Then you need use a Win32API function SetParent, and that all you need.
On the SetParent page is little sample, which should do what you need.

Categories