minimize application to sys tray

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

i've created an application and i want it to be minimized to the sys tray,
how i do it?
if you can direct me step by step even with create a small application and
put it in the sys tray

Thanks
 
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you are trying
to do.

Hope this helps.
 
ok i found half way, this is the code that when i press double click on the
sys tray icon the application minimized

private void notifyIcon1_MouseDoubleClick(object sender,
MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
this.WindowState = FormWindowState.Minimized;

// Activate the form.
this.Activate();
}

now i want the code that if i press again double click on the sys tray icon
it will lunch back the application and if the application is lunch and i
press the sys tray icon again it will minimized, how i do it?

Thanks

Nicholas Paldino said:
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you are trying
to do.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Avi G said:
Hi,

i've created an application and i want it to be minimized to the sys tray,
how i do it?
if you can direct me step by step even with create a small application and
put it in the sys tray

Thanks
 
Hello Avi,

Just reverse operation

if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;


AG> ok i found half way, this is the code that when i press double click
AG> on the sys tray icon the application minimized
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> // Activate the form.
AG> this.Activate();
AG> }
AG> now i want the code that if i press again double click on the sys
AG> tray icon it will lunch back the application and if the application
AG> is lunch and i press the sys tray icon again it will minimized, how
AG> i do it?
AG>
AG> Thanks
AG>
AG> "Nicholas Paldino [.NET/C# MVP]" wrote:
AG>
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you are
trying to do.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi,

i've created an application and i want it to be minimized to the sys
tray,
how i do it?
if you can direct me step by step even with create a small
application and
put it in the sys tray
Thanks
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
i try your suggestion earlier but it cannot work like that

private void notifyIcon1_MouseDoubleClick(object sender,
MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
this.WindowState = FormWindowState.Minimized;


this.Activate();



if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Activate();

}

if i try this it cannot minimized or normal because he do the code
together, any other suggestion

Michael Nemtsev said:
Hello Avi,

Just reverse operation

if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;


AG> ok i found half way, this is the code that when i press double click
AG> on the sys tray icon the application minimized
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> // Activate the form.
AG> this.Activate();
AG> }
AG> now i want the code that if i press again double click on the sys
AG> tray icon it will lunch back the application and if the application
AG> is lunch and i press the sys tray icon again it will minimized, how
AG> i do it?
AG>
AG> Thanks
AG>
AG> "Nicholas Paldino [.NET/C# MVP]" wrote:
AG>
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you are
trying to do.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

i've created an application and i want it to be minimized to the sys
tray,
how i do it?
if you can direct me step by step even with create a small
application and
put it in the sys tray
Thanks
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Hello Avi,

Check the current state and use only one case

private void notifyIcon1_MouseDoubleClick(object sender,MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
}
else
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal
}

this.Activate();
}

AG> i try your suggestion earlier but it cannot work like that
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> this.Activate();
AG>
AG> if (this.WindowState == FormWindowState.Minimized)
AG> this.WindowState = FormWindowState.Normal;
AG> this.Activate();
AG> }
AG>
AG> if i try this it cannot minimized or normal because he do the code
AG> together, any other suggestion
AG>
AG> "Michael Nemtsev" wrote:
AG>
Hello Avi,

Just reverse operation

if (this.WindowState == FormWindowState.Minimized) this.WindowState =
FormWindowState.Normal;

AG> ok i found half way, this is the code that when i press double
click
AG> on the sys tray icon the application minimized
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> // Activate the form.
AG> this.Activate();
AG> }
AG> now i want the code that if i press again double click on the sys
AG> tray icon it will lunch back the application and if the
application
AG> is lunch and i press the sys tray icon again it will minimized,
how
AG> i do it?
AG>
AG> Thanks
AG>
AG> "Nicholas Paldino [.NET/C# MVP]" wrote:
AG>
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you
are trying to do.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi,

i've created an application and i want it to be minimized to the
sys
tray,
how i do it?
if you can direct me step by step even with create a small
application and
put it in the sys tray
Thanks
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
thanks it's working, now last question if i want to minimize the application
to the sys tray directly and not to the toolbar and be able to lunch it back
from the sys tray icon and minimize it back to the sys tray, how i do it?

Michael Nemtsev said:
Hello Avi,

Check the current state and use only one case

private void notifyIcon1_MouseDoubleClick(object sender,MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
}
else
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal
}

this.Activate();
}

AG> i try your suggestion earlier but it cannot work like that
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> this.Activate();
AG>
AG> if (this.WindowState == FormWindowState.Minimized)
AG> this.WindowState = FormWindowState.Normal;
AG> this.Activate();
AG> }
AG>
AG> if i try this it cannot minimized or normal because he do the code
AG> together, any other suggestion
AG>
AG> "Michael Nemtsev" wrote:
AG>
Hello Avi,

Just reverse operation

if (this.WindowState == FormWindowState.Minimized) this.WindowState =
FormWindowState.Normal;

AG> ok i found half way, this is the code that when i press double
click
AG> on the sys tray icon the application minimized
AG>
AG> private void notifyIcon1_MouseDoubleClick(object sender,
AG> MouseEventArgs e)
AG> {
AG> if (this.WindowState == FormWindowState.Normal)
AG> this.WindowState = FormWindowState.Minimized;
AG> // Activate the form.
AG> this.Activate();
AG> }
AG> now i want the code that if i press again double click on the sys
AG> tray icon it will lunch back the application and if the
application
AG> is lunch and i press the sys tray icon again it will minimized,
how
AG> i do it?
AG>
AG> Thanks
AG>
AG> "Nicholas Paldino [.NET/C# MVP]" wrote:
AG>
Avi,

Check out the NotifyIcon class. The about page for the class
documentation in MSDN has an example which will show you what you
are trying to do.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi,

i've created an application and i want it to be minimized to the
sys
tray,
how i do it?
if you can direct me step by step even with create a small
application and
put it in the sys tray
Thanks
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Avi said:
thanks it's working, now last question if i want to minimize the application
to the sys tray directly and not to the toolbar and be able to lunch it back
from the sys tray icon and minimize it back to the sys tray, how i do it?
this.Hide() and this.Show()

<...>
JB
 
i managed to hide the application but not to restore it back, why what i
wrong with my code?

private void notifyIcon1_MouseDoubleClick(object sender,
MouseEventArgs e)
{

if (this.WindowState == FormWindowState.Normal)
{
this.Hide();
}

else
if (this.WindowState == FormWindowState.Minimized)

{

this.Show();

}



}
 
Back
Top