Code for implementing form jitter using winform

Source: Internet
Author: User

As we all know, winform provides the form jitter function in current instant messaging tools. This function is also set up to notify the other party in a timely manner, today, we will use the C # version of winform to implement the form mixing function!

Train of Thought: after a certain period of time, the position of the form must be changed around the starting position; otherwise, the form will be moved.

The Code is as follows:

UsingSystem;
UsingSystem. drawing;
UsingSystem. Windows. forms;

NamespaceTwitter
{
    PublicPartialClassForm1
: Form
   {
        PublicForm1 ()
       {
           Initializecomponent ();
       }

        PrivateVoidButton#click (ObjectSender,
Eventargs E)
       {
           Random ran=NewRandom ((INT) datetime. Now. ticks );
           Point point=This. location;
            For(IntI=0;
I<40;
I ++)
           {
                This. Location=NewPoint (point. x+Ran. Next (8)-4,
Point. Y+Ran. Next (8)-4 );
               System. Threading. thread. Sleep (15 );
                This. Location=Point;
               System. Threading. thread. Sleep (15 );
           }
       }
   }
}

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.