private void T2_MouseMove(object sender, MouseEventArgs e) { var ctrl = sender as TextBox; var x = e.X; var y = e.Y; //dm.GetCursorPos(out x, out y); if (hwnd > 0) { var r = dm.GetWindowRect(hwnd); x -= r.X; y -= r.Y; } ctrl.Text = x + "," + y; }