예제 #1
0
 private static SCapture.CursorInfo GetCursorInfo()
 {
     SCapture.CursorInfo cursorInfo = default(SCapture.CursorInfo);
     cursorInfo.cbSize = checked ((uint)Marshal.SizeOf(cursorInfo));
     if (!SCapture.UnsafeNativeMethods.GetCursorInfo(ref cursorInfo))
     {
         int lastWin32Error = Marshal.GetLastWin32Error();
         throw new SCaptureException(new Win32Exception(lastWin32Error).Message);
     }
     return(cursorInfo);
 }
예제 #2
0
 private static void DrawCursor(Rectangle rect, Bitmap bmp)
 {
     SCapture.CursorInfo cursorInfo = SCapture.GetCursorInfo();
     checked
     {
         if (cursorInfo.flags == 1u && rect.Contains(cursorInfo.ptScreenPos))
         {
             IntPtr            cursorIcon = SCapture.GetCursorIcon(cursorInfo.hCursor);
             SCapture.IconInfo iconInfo   = SCapture.GetIconInfo(cursorIcon);
             Graphics          graphics   = Graphics.FromImage(bmp);
             graphics.DrawIcon(Icon.FromHandle(cursorIcon), (int)(unchecked ((long)(checked (cursorInfo.ptScreenPos.X - rect.X))) - (long)(unchecked ((ulong)iconInfo.xHotspot))), (int)(unchecked ((long)(checked (cursorInfo.ptScreenPos.Y - rect.Y))) - (long)(unchecked ((ulong)iconInfo.yHotspot))));
             graphics.Dispose();
         }
     }
 }
예제 #3
0
 public static extern bool GetCursorInfo(ref SCapture.CursorInfo pci);