我尝试将光标设置在窗体内的特定位置,当窗体最大化时可以正常但是当窗体大小改变时,光标位置在窗体之外
抱歉我的英文。
private void button1_Click(object sender, EventArgs e)
{
int xp = 585;
int yp = 330;
Cursor.Position = PointToClient(new Point(xp, yp));
Point mousep = PointToClient(Cursor.Position);
tbX1.Text = mousep.X.ToString();
tbY1.Text = mousep.Y.ToString();
}
答案 0 :(得分:1)
如果变量xp和yp是窗口内的偏移量......
Cursor.Position = new Point(Location.X + xp, Location.Y + yp);