C # interface design. You can move the effect by dragging the mouse without borders,

Source: Internet
Author: User

C # interface design. You can move the effect by dragging the mouse without borders,

Add variable at the beginning:


Point mouseOff; // the variable that moves the cursor.

Bool leftFlag; // whether the label is left

 

Event section:

 

1 private void Login_MouseMove (object sender, MouseEventArgs e) 2 {3 // Point to Detection 4 if (leftFlag) 5 6 {7 8 Point mouseSet = Control. mousePosition; 9 10 mouseSet. offset (mouseOff. x, mouseOff. y); // set the Moving position 11 12 Location = mouseSet; 13 14} 15 // 16} 17 18 private void Login_MouseUp (object sender, MouseEventArgs e) 19 {20 21 if (leftFlag) 22 23 {24 25 leftFlag = false; // After the mouse is released, mark it as false; 26 27} 28} 29 30 private void Login_MouseDown (object sender, mouseEventArgs e) 31 {32 if (e. button = MouseButtons. left) 33 34 {35 36 mouseOff = new Point (-e. x,-e. y); // get the variable value 37 38 leftFlag = true; // click the left button to press the time mark to true; 39 40} 41}

Ps: a few common characters.

Remember! Remember! Remember!

Related Article

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.