简体   繁体   English

在面板中移动鼠标光标

[英]Moving mouse cursor in panel

I'm trying to move my cursor to a position from my panel, when I try this my cursor moves, but not to my panel's position but to that of the main menu, does anyone know what to do to get the position of my panel ?我正在尝试将光标移动到面板的某个位置,当我尝试此操作时,我的光标移动,但不是移动到面板的位置,而是移动到主菜单的位置,有谁知道如何获取面板的位置?

this.Cursor = new Cursor(Cursor.Handle);
Cursor.Position = new Point(attach.X, attach.Y);

When setting Cursor 's coorinates you should provide screen coordinates, not local ones.设置Cursor的坐标时,您应该提供屏幕坐标,而不是本地坐标。 Assuming attach.X, attach.Y are coordinates on myPanel :假设attach.X, attach.Y是在坐标myPanel

 Cursor.Position = myPanel.PointToScreen(new Point(attach.X, attach.Y));

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

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