minimize - C# close to tray (like msn messenger) -


I have a C # .net app so I made a notice that sits in the tray. What I want to do, when the user hits the "x" button on the form, I want to pass it to the tray. They should be able to exclude the program using the context menu in the tray icon.

So what I did, when the form closes, I check whether the form is visible or not. If it is visible, then I set it in invisible and set the Show Interscape to false (to reduce the routing) if the form is already invisible, then maybe they are closing it with the tray, so I In case, exit from the program.

However, I have the problem that if the window is appearing, but they click on the context menu of the tray icon and press exit, I need to exit the program and at least not less.

How can I solve this problem?

Try this:

  bool _ shutting down menu; Zero NOTIFYICON_EXIT_MENU_HANDLER (Object Sender, EventArgs e) {_closingFromMenu = true; Close (); } // Form Off Handler FormClosing + = (a, b) = & gt; {If (_closingFromMenu) {Close (); } And (E. canal = true; // reduce the content;}}  

or if you have only one form, then you can apply for .exit () ; in context menu item handler


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -