Пример #1
0
        public void UpdateCursorData()
        {
            CursorInfo cursorInfo = new CursorInfo();
            cursorInfo.cbSize = Marshal.SizeOf(cursorInfo);

            if (NativeMethods.GetCursorInfo(out cursorInfo))
            {
                IsVisible = cursorInfo.flags == NativeMethods.CURSOR_SHOWING;

                if (IsVisible)
                {
                    IconHandle = NativeMethods.CopyIcon(cursorInfo.hCursor);
                    IconInfo iconInfo;

                    if (NativeMethods.GetIconInfo(IconHandle, out iconInfo))
                    {
                        Point cursorPosition = CaptureHelpers.GetZeroBasedMousePosition();
                        Position = new Point(cursorPosition.X - iconInfo.xHotspot, cursorPosition.Y - iconInfo.yHotspot);

                        if (iconInfo.hbmMask != IntPtr.Zero)
                        {
                            NativeMethods.DeleteObject(iconInfo.hbmMask);
                        }

                        if (iconInfo.hbmColor != IntPtr.Zero)
                        {
                            NativeMethods.DeleteObject(iconInfo.hbmColor);
                        }
                    }
                }
            }
        }
Пример #2
0
 public static extern bool GetCursorInfo(out CursorInfo pci);