Exemplo n.º 1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="CaptureCursor"/> class.
        /// </summary>
        /// 
        public CaptureCursor()
        {
            // By preallocating those we will prevent extra
            // object allocations in middle of processing.

            IntPtr desk = NativeMethods.GetDesktopWindow();
            using (Graphics desktop = Graphics.FromHwnd(desk))
                mask = SafeNativeMethods.CreateCompatibleDC(desktop);

            cursorInfoSize = Marshal.SizeOf(typeof(CursorInfo));
        }
        /// <summary>
        ///   Creates a device context compatible with the specified surface.
        /// </summary>
        /// 
        public static DeviceHandle CreateCompatibleDC(Graphics graphics)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            IntPtr source = graphics.GetHdc();

            IntPtr handle = NativeMethods.CreateCompatibleDC(source);
            DeviceHandle dc = new DeviceHandle(handle);

            graphics.ReleaseHdc(source);

            return dc;
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Creates a device context compatible with the specified surface.
        /// </summary>
        ///
        public static DeviceHandle CreateCompatibleDC(Graphics graphics)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            IntPtr source = graphics.GetHdc();

            IntPtr       handle = NativeMethods.CreateCompatibleDC(source);
            DeviceHandle dc     = new DeviceHandle(handle);

            graphics.ReleaseHdc(source);

            return(dc);
        }
Exemplo n.º 4
0
 /// <summary>
 ///   Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// 
 /// <param name="disposing"><c>true</c> to release both managed
 /// and unmanaged resources; <c>false</c> to release only unmanaged
 /// resources.</param>
 ///
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // free managed resources
         mask.Dispose();
         mask = null;
     }
 }