繁体   English   中英

WinForms中的光标位置

[英]Cursor position inside WinForms

我尝试将光标设置在表单内的特定位置,当表单最大化时可以,但是当表单的大小更改时,游标位置不在表单外部

对不起我的英语不好。

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();
}

假设变量xp和yp是窗口内的偏移量...

Cursor.Position = new Point(Location.X + xp, Location.Y + yp);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM