How to make a mouse follow-up window--simple

Source: Internet
Author: User

Just like QQ pet or Thunder hover window, mouse click down the form to follow the mouse move

The main is two time loading

MouseDown and MouseMove Events

MouseDown event:

1         private int _startx;//mouse point down the coordinates 2         private int _starty; 3         private void Form1_mousedown (object sender, MouseEventArgs e) 4         {5             _startx = e.x;//e is the mouse punctuation event 6             _starty = e.y;7         }

MouseMove Events

1 private void Form1_mousemove (object sender, MouseEventArgs e) 2         {3             if (E.button = = System.Windows.Forms.Mous Ebuttons.left) 4             {5 this                 . Left + = e.x-_startx;//minus the coordinates of the mouse point is the window that moves the position under the point 6 this                 . Top + = e.y-_starty;7             }8         }

If inside

E.button = = System.Windows.Forms.MouseButtons.Left Perform a move event when the left mouse button is down
If you do not add---the action of the form will be performed when the mouse moves over the form

How to make a mouse follow-up window--simple

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.