Get and set mouse position
Can any one tell me....
How to get and set mouse position within form(for window application)? I am using c# 2008 studio.
I am new to it , so please reply though the question is stupid.
private void Form1_MouseDown(object sender, MouseEventArgs e) { // get mouse position relative to Screen int offsetFrom_ScreenOrigin_X = Cursor.Position.X; int offsetFrom_ScreenOrigin_Y = Cursor.Position.Y; // set mouse position relative to screen, e.g. at pixel (100, 100) Cursor.Position = new Point(100, 100); // get mouse position relative to a control (must be in any mouse event function) int offsetFrom_Form1Origin_X = e.X; int offsetFrom_Form1Origin_Y = e.Y; // set mouse position relative to a control, e.g. at pixel (100, 100) Cursor.Position = this.PointToScreen(new Point(100, 100)); }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement