fancy closing of a C#. How?

Hi there;

I want my form to be closed pixelated in C#. Is it possible? Could you provide me a link?

Kind regards.
LVL 12
jazzIIIloveAsked:
Who is Participating?
 
Carlos VillegasConnect With a Mentor Full Stack .NET DeveloperCommented:
I know that you are asking for a pixelate effect, but maybe you are interested in this fading effect:
public partial class Form1 : Form
{
    bool fading = false;
    bool fadingComplete = false;
    System.Windows.Forms.Timer myTimer = null;

    public Form1()
    {
        InitializeComponent();
    }

    protected override void OnClosing(CancelEventArgs e)
    {
        if (fading && !fadingComplete)
        {
            e.Cancel = true;
            return;
        }

        if (!fading)
        {
            fading = true;
            myTimer = new System.Windows.Forms.Timer();
            myTimer.Interval = 50;
            myTimer.Tick += new EventHandler(myTimer_Tick);
            myTimer.Start();
            e.Cancel = true;
            return;
        }

        base.OnClosing(e);
    }

    void myTimer_Tick(object sender, EventArgs e)
    {
        if (this.Opacity > 0)
        {
            this.Opacity -= 0.1;
        }
        else
        {
            myTimer.Stop();
            fadingComplete = true;
            this.Close();
        }
    }
}

To test, create a new windows forms project and replace the Form1 class with this.

Open in new window

0
 
Kalpesh ChhatralaConnect With a Mentor Software ConsultantCommented:
0
 
jazzIIIloveAuthor Commented:
good :)
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Glad to help buddy!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.