Thread: close window

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    58

    close window

    hi,
    i want to keep main form when clicking close button (form closing event).
    so it has to close after process some condition statement.
    here are some code.

    Code:
    private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (active_flag && checkLogin())
                    this.Close();
                else
                    //keep form
            }
    how can i fix it?
    regards

  2. #2
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Use the e.Cancel boolean.

    Code:
    if (we don't want to allow the window to close)
        e.Cancel = true;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 07:23 AM
  4. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM