Hw to ...

  • Thread starter Thread starter Jacek Jurkowski
  • Start date Start date
What's the difference? I just want to store my
window into a system tray and restore it to the user
on tray icon click ...
 
What's the difference? I just want to store my
window into a system tray and restore it to the user
on tray icon click ...

What's the difference between what and what? If you want to place you
window in the system tray, then use a Notify Icon as suggested. Handle the
Resize event of your form and if it's minimized, hide it. Then handle the
Click event of your notify icon and show your form again.
 
Visible = false;

or

this.Hide();

Why thouse cleses "releases" my Window?
I want to hide and restore , not to release ...
Which method to use?
 
Visible = false;

or

this.Hide();

Why thouse cleses "releases" my Window?
I want to hide and restore , not to release ...
Which method to use?

I guess that in your Main method, you have something like that:
Application.Run(new Form1());

where Form1 is the name of your main form. In this case, when your main
form closes or is hiden, the message loop started by Application.Run is
stopped and your application closes.

To avoid this behaviour, make your message loop independent from your form.
Replace the above line by:

Form1 f = new Form1();
f.Show();
Application.Run();

Now you can hide and show your form without the message loop stopping
itself automatically. Keep in mind however that it is now your task to stop
the message loop with Application.Exit() as the message loop is not linked
with your main form anymore. So handle the Closing event of your main form
and call Application.Exit() there.
 
Back
Top