[StructLayout(LayoutKind.Sequential)]
        public struct POINT
        {
            public int X;
            public int Y;
 
            public POINT(int x, int y)
            {
                this.X = x;
                this.Y = y;
            }
 
            public override string ToString()
            {
                return ("X:" + X + ", Y:" + Y);
            }
        }
 
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern bool GetCursorPos(out POINT pt);


使用:

 POINT currentPosition = new POINT();
                GetCursorPos(out currentPosition);
 
                System.Diagnostics.Debug.WriteLine("Current mouse point: " + currentPosition.ToString());
 
//转为客户区域坐标
                Point relativePos = itemsControl.PointFromScreen(new Point(currentPosition.X, currentPosition.Y));

相关文章:

  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2022-03-07
相关资源
相似解决方案