마우스로 그래픽 객체를 움직이는 그래픽 응용 프로그램이 있습니다.마우스 정지 또는 이동
일부 조건에서는 개체가 움직이지 않습니다. 마우스 커서도 움직이지 않아야합니다.
가능합니까? MousePosition
속성이 ReadOnly에있는 것 같습니다.
예 :
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.X > 100)
{
Cursor.Position = new Point(100, Cursor.Position.Y);
}
}
}
편집, 두 번째 버전은 작동하지만, 커서는 "안정"아니다 - 깜박임 :
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.X > 100)
{
Point mousePosition = this.PointToClient(Cursor.Position);
mousePosition.X = 100;
Point newScreenPosition = this.PointToScreen(mousePosition);
Cursor.Position = newScreenPosition;
}
}
'{0, 0, 100, Form.Height}' (분명히 클라이언트 좌표에서 화면 좌표로 변환). – GSerg