光标的坐标

mingcsharp 2009-12-05 11:11:12
问个小题,
1.当光标在屏幕上移动时
怎么能得到光标的坐标
2.怎么得到光标下面控件的句柄?
...全文
34 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
grzx2210 2009-12-05
  • 打赏
  • 举报
回复
有win32ApI看以,
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int GetDC(int hwnd);
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] //确定坐标
private static extern int ReleaseDC(int hwnd, int hdc);
POINTAPI P; //确定坐标


[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int ScreenToClient(int hwnd, ref POINTAPI lpPoint);
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]//获取窗体句柄
private static extern int WindowFromPoint(int xPoint, int yPoint);

hzxsasdfgh 2009-12-05
  • 打赏
  • 举报
回复
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
label1.Text=string.Format("哈哈捕捉到鼠标位置了!{0},{1}", e.X, e.Y);

}
sohighthesky 2009-12-05
  • 打赏
  • 举报
回复

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧