954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to make form disapper not close ( like msn messenger)

Hi there. i am new to C# programming. I am developing an updater that would update our product. I want to program the close button so if clicked the application should not close but rather hide. I have a notification icon from where the user can call it back. I want it just like in msn messenger.

Umair.P
Newbie Poster
17 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

try Hide and Show for the form

//Hides 
Form.Hide();
//you can use this if you are in the form's code
this.Hide();

//Show the form
Form.Show();
//in the form's code
this.Show();
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
 

Hi there. I have done it my self. Thought it would be better to share. What I wanted to do was to use notification Icon and when user clicks close button the applicaton should hide and the user could call it back by clicking on the notification icon.
The following is the code written in form_close event

e.cancel;
this.hide();
Umair.P
Newbie Poster
17 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

Hi,
This is working but sometimes u need to close the form then ..
Make a boolean variable. then check it for close operation.

Try

bool bUserClose = true;
    private void Form1_Click(object sender, EventArgs e)
    {
        bUserClose = false;
        Close();
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (bUserClose)
        {
            e.Cancel = true;
            Hide();
        }
    }
selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You