systemTray-only application always has an open window - c#

I'm developing C# a WPF application where all windows are hidden/closed by default. I have a system tray Icon (System.Windows.Forms.NotifyIcon) with a context menu to show/hide the windows. All windows have ShowInTaskbar="False".
The problem is that the startup windows is still visible when I press alt+tab.
If I close the form that has the NotifyIcon my application stops, which I don't want.
I'm looking for a way to hide the windows completely without closing my application.
Any help?
Thanks

Make sure you have BOTH ShowInTaskbar="False" and Visibility="Hidden" set in the XAML and WPF should do this automatically.
The cause is likely you have window state set to minimized instead of visibility set to hidden.

Related

MFC app - Class library WPF window icon does not show up in taskbar

I have an MFC window-based app. I added a C# class library that provides a second window for login to the app. This second window is meant to show before the main MFC window and once the user successfully logs in, it will go away and the main window will launch. The problem I am having is that when the login window is showing there is no taskbar icon for it. This did work correctly when the login window was an MFC dialog.
To make debugging this window easier I made a small MFC test app from which I can launch the login window with a button click. (the main program is cumbersome to test with). I added a C# class library to it just as it is in the main program. When I launch the app the main MFC dialog app shows up and the app's icon appears on the taskbar. When I click the button to launch the WPF window, it appears but there is no icon in the taskbar. This window does not show on the taskbar as a second window of the app as I would expect.
I am having a really hard time with google finding relevant info.
I have tried specifying an icon for the window vs. not specifying one.
I have tried adding ShowInTaskbar="True" to the window.
I have tried changing WindowStyle
I have tried playing with TaskbarItemInfo.
I tried following New taskbar icon when opening a window in WPF, but I don't really understand it well enough to say that it will fix my issue since I do not get my window showing up at all and if I did I would be fine with it being stacked.
I am not sure where else to go with this. Please let me know if there is anything unclear.

Place an application's icon into system tray

I'm making a desktop mascot with unity, and I do not want to see the icon appearing on the task bar, I want the icon in the system tray. Is there a way to do this?
PS: This is NOT a windows form (it's a game), so I believe Form.ShowInTaskbar will not work.
I've never programmed in Unity, but I'm assuming you are working in a Windows window. If you make the top level window for the application not appear in the main area of the Taskbar, make the window a "Tool Window" (by setting the WS_EX_TOOLWINDOW extended style on the window), then the window/app will not show up on the taskbar.
I'll leave it to someone how knows enough Unity to tell you how to set that style. Here's a reference to start with (on the Windows side, not the Unity side): Managing Taskbar Buttons

c# taskbar button switching/moving in multiple display environment

I've created a winforms application. All is running fine, also the taskbar button is created and shown in taskbar including the correct icon.
Whenever I move the form from one display to the second display, the taskbar button stays at the display from where the form was initial start.
I also compared the settings with another winforms application where the behaviour is correct. Means, the button is moving/switching/whatever to the active display where the form is moved to.
Hopefully it is just a small thing, but I came not across with it.
It is an OS feature.
For windows 7 there is no built-in support to show taskbar for your second monitor and your taskbar buttons will always show on first monitor taskbar.
For windows 8 you can open Taskbar properties and in Multiple displays settings, check Show taskbar on all displays and then set the value of Show taskbar bottons on: to Taskbar where window is open

Minimize application just like in Windows 7

How do you make a WPF C# application minimize like Windows 7, when the user presses the minimize button?
Edit
Createde a button that could do this:
WindowState = WindowState.Minimized;
But it minimize instantly and not shrinking to taskbar like when you minimize a folder in windows 7
It will happen by default if you haven't played with the window properties too much in the designer or XAML. So if you haven't changed anything, you don't actually need to do anything to get this to work - assuming you are at least displaying the stuff in a window.
To resize a WPF window in code, please refer to this question:
Minimize a window in WPF?

Don't show window on shell tray

I want to create a gadget. when opening windows they appear on the shell tray as:
how can I prevent a window from showing on that tray. I already know how to send a window to the back to make it appear as a gadget. I found that example in here. It will be nice if that menu does not show up meanwhile the window is active and open.
Use the Window property ShowInTaskbar to restrict or allow your Window to appear in the taskbar.

Categories

Resources