C # making a flashing form

Source: Internet
Author: User

C # Making flashing forms This article describes how to use C # to create a flashing form. Create a new Windows Forms application and add a button click event. All programs are as follows:
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;using system.threading;namespace _2_fun_with_if_else        {public partial class Form1:form {public Form1 () {InitializeComponent ();            } private void Button1_Click (object sender, EventArgs e) {while (Visible)//Close the form, stop looping {for (int c = 0; c < 254 && Visible; C + +) {this. BackColor = Color.FromArgb (c, 255-c, C);                    This method specifies a number of three digits: Red/green/blue. Application.doevents (); This statement enables the operating system to perform other operations outside of the program. otherwise//The program will occupy all CPU cycles thread.sleep (3);                This statement inserts a delay of 3 milliseconds in the loop. } for (int c = 254, c >= 0 && Visible; c--) {this.                   BackColor = Color.FromArgb (c, 255-c, C); Application.doevents ();                Thread.Sleep (3); }            }        }    }}
Post-run effects

C # making a flashing form

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.