Drag the mouse to move coordinates

Source: Internet
Author: User

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;namespace Mouse Drag move coordinates {public ' partial class Form1:form {public F        Orm1 () {InitializeComponent ();        } private bool isOK; private int x;        Mouse point down the horizontal axis private int y;//Mouse point down the ordinate private int cx;        private int cy;            private void Form1_mousedown (object sender, MouseEventArgs e)//point down {isOK = true; x = cursor.position.x; Mouse point down when the form of the horizontal axis y = cursor.position.y;//Mouse point down when the form of the ordinate CX = this. location.x;//form Initial horizontal axis cy = this.            location.y;//form initial ordinate} private void Form1_mouseup (object sender, MouseEventArgs e)//release {        isOK = false;                } private void Form1_mousemove (object sender, MouseEventArgs e)//move {if (isOK) { int Movex= cursor.position.x; The horizontal axis of the move process int Movey = cursor.position.y;//The ordinate this of the move process. Location = new Point (CX+MOVEX-X,CY+MOVEY-Y); Initial coordinates + moving coordinates-the mouse at the beginning of the point down the coordinates}}}}

  

Drag the mouse to move coordinates

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.