マウスの座標を取得する(グローバルな座標)
System.Windows.Forms.Cursor.Position
フォーム内の座標が取りたい場合には、
System.Drawing.Point pointMouse = this.PointToClient(System.Windows.Forms.Cursor.Position);
フォームの座標
this.Location
これを合わせて、FormのMouseEnterの
イベントハンドラーに下記の様な呪文を入れると、マウスがフォームに入るたびにフォームが動き回って、なかなかやらしい。
private void onMouseEnter(object sender, EventArgs e)
{
this.Location = new Point(System.Windows.Forms.Cursor.Position.Y, System.Windows.Forms.Cursor.Position.X);
}