views:

208

answers:

3

I'm writing a C# Windows Form application, and I'm trying to figure out how to hide the form while keeping it active in the windows taskbar.

I've tried setting the Visible property to false and using the Hide() method, but they hide both the form and the taskbar entry.

I've also tried minimizing the app permanently by setting WindowState to FormWindowState.Minimized in the OnLoad and onResize events. This works pretty well but when you left-click on the icon in the taskbar, you get a quick flash of the application before it resizes (which is kind of annoying).

Sorry if this question has come up before, but every question that I've seen so far invovles hiding the taskbar completely, or removing the application as a taskbar item (to be replaced by a NotifyIcon).

Anyone have any ideas? Thanks!

+5  A: 

Shouldn't you maybe be using a notify icon for this?

ParmesanCodice
On a side note has anyone has success with the NotifyIcon project in SharpDevelop?
ParmesanCodice
Yeah, i should, but I'm playing around with Windows7 Jumplists and they kinda *need* an active window.
Jama22
+2  A: 

Set

FormBorderStyle = None

& in Load event:

private void Form1_Load(object sender, EventArgs e)
{
    this.Size = new System.Drawing.Size(0, 0);
}
najmeddine
works like a charm, thanks you guys are awesome
Jama22
+3  A: 

As dequadin mentioned, the paradigm you're using probably justifies a notify icon. The taskbar is specifically designed for minimized windows (and on Win7, app launch). All of the other recommendations (form opacity, moving the window offscreen, etc) fall down on Win7 with Aero Peek.

If you have an app which is primarily a background task with occasional UI and the need for user interaction on demand, the correct technique is the System Notification Area (aka the Tray). In .NET WinForms, this would be the NotifyIcon control.

John Rudy
Thanks John, that's exactly what I mean just in a lot more words.
ParmesanCodice