NotifyIcon

P

Peter Holschbach

Hi all,

I've a application where I need to use NotifyIcon in a other way round. My normal windows application sometimes has to collect data. In this case I want to hide all formulares and just show a icon in the system tray.
I've added a NotifyIcon and a button to a form:

private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
notifyIcon1.Visible = true;
}

click on the button hides the formular (perfect) but it also hides the icon in the system tray (not what I intended :-()
any idea ?

thanx
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What you mean with hide the Icon in the system tray?

IIRC the way of doing it is to make the window minimized.

Take a look at my post here http://www.thescripts.com/forum/thread265639.html


--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Hi all,

I've a application where I need to use NotifyIcon in a other way round. My normal windows application sometimes has to collect data. In this case I want to hide all formulares and just show a icon in the system tray.
I've added a NotifyIcon and a button to a form:

private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
notifyIcon1.Visible = true;
}

click on the button hides the formular (perfect) but it also hides the icon in the system tray (not what I intended :-()
any idea ?

thanx
 
B

Bjørn Brox

Peter Holschbach skrev:
Hi all,

I've a application where I need to use NotifyIcon in a other way round.
My normal windows application sometimes has to collect data. In this
case I want to hide all formulares and just show a icon in the system tray.
I've added a NotifyIcon and a button to a form:

private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
notifyIcon1.Visible = true;
}

click on the button hides the formular (perfect) but it also hides the
icon in the system tray (not what I intended :-()
any idea ?
Wild guess: Set notify icon visible first, and then perform a hide().
I guess using Hide() does a better job than just setting the visible
variable.
The notifyIcon1 Click action is of course this.show().

notifyIcon1.Visible = true;
this.Hide();
 
B

Ben Voigt [C++ MVP]

Peter said:
Hi all,

I've a application where I need to use NotifyIcon in a other way
round. My normal windows application sometimes has to collect data.
In this case I want to hide all formulares and just show a icon in
the system tray.
I've added a NotifyIcon and a button to a form:

private void button1_Click(object sender, EventArgs e)
{
this.Visible = false;
notifyIcon1.Visible = true;
}

click on the button hides the formular (perfect) but it also hides
the icon in the system tray (not what I intended :-()
any idea ?

What if the NotifyIcon wasn't parented to the Form? Setting Visible false
on a container automatically overrides Visible for all children (the
children will remember the setting but will not use it until the parent
becomes Visible=true again).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top