public struct POINT
{
public int X;
public int Y;
public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out POINT lpPoint);
//e.GetPosition(this);
//(e.Source as FrameworkElement).PointToScreen(new Point(0, 0));
POINT mousestart = new POINT();
GetCursorPos(out mousestart);
Point p2 = Mouse.GetPosition(this as FrameworkElement);
Point p = Mouse.GetPosition(e.Source as FrameworkElement);
MessageBox.Show(Convert.ToString(mousestart.X));
MessageBox.Show(Convert.ToString(p.X));
MessageBox.Show(Convert.ToString(p2.X));
原文地址:https://www.cnblogs.com/lonelyxmas/p/9795403.html
时间: 2024-10-06 02:16:48