C # Tray Program instance double-click the display form to minimize to the pallet

Source: Internet
Author: User
Click Taskbar Display-Hide toggle, context menu, snap close form event

 Public partial class Frmmain:form {public Frmmain () {InitializeComponent (); #region Unregister public void Logout () {if (MessageBox.Show ("Confirm to exit?                "," hint ", messageboxbuttons.okcancel) = = DialogResult.OK) {notifyicon1.visible = false;                FormCollection FC = Application.openforms; if (FC! = NULL && FC.                        Count > 0) {foreach (Form window in FC) { Window.                    Hide ();                }} cachehelper.currentusrname = "";                Cachehelper.currentroleid = 0;                Frmlogin fl = new Frmlogin (); Fl.            Show ();        }} private void Logout login Toolstripmenuitem_click (object sender, EventArgs e) {Logout (); } #endregion #region Change password private void Change password Toolstripmenuitem_click (object seNDEr, EventArgs e) {frmchangepwd FCP = new Frmchangepwd (); Fcp.        Show (); } #endregion private void Frmmain_load (object sender, EventArgs e) {} private void frm Main_formclosing (object sender, FormClosingEventArgs e) {if (MessageBox.Show ("Confirm to exit?")            "," hint ", messageboxbuttons.okcancel) = = DialogResult.OK) {Logout ();            } else {e.cancel = true;        }} private void maximized Toolstripmenuitem_click (object sender, EventArgs e) {Showwin ();        } private void Exits Toolstripmenuitem_click (object sender, EventArgs e) {Logout (); The private void Frmmain_sizechanged (object sender, EventArgs e) {if (this.            WindowState = = formwindowstate.minimized) {Hidewin (); }} private void Notifyicon1_mouseclick (ObjeCT sender, MouseEventArgs e) {if (E.button = = mousebuttons.right) {Contextme            Nustrip1.show (mouseposition.x, MOUSEPOSITION.Y);            } else {Showwin (); }} #region hide the show form///<summary>///Hide Form///</summary> private Voi            D Hidewin () {this.notifyIcon1.Visible = true; This.        Hide ();            }///<summary>///Show main form//</summary> private void Showwin () {            if (Visible) {Hidewin ();                } else {/////Note here The order is important, first show after the set State Show ();            WindowState = Formwindowstate.normal; }} #endregion}

The above is the C # Tray program instance double-click the Display form, to minimize the contents of the tray, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.