How can I track the cursor relatively to my windows Form C#

Viewed 43

I know how to track the cursor with Form1.MousePosition but it gives me cursor position relative to the screen, not actual form. Is there a way to track it relative to the Form? Even when I move it (its 1000*1000)! I really appreciate any help you can provide.

1 Answers

You could register on the MouseMove event of the Form.

this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);


private void Form1_MouseMove(object sender, MouseEventArgs e)
{
    // e.Location.X;
    // e.Location.Y;
}
Related