Exemple #1
0
        public static void DrawDragOutline(Region region)
        {
            if (region == null)
                return;

            // Get hold of the DC for the desktop
            IntPtr hDC = User32.GetDC(IntPtr.Zero);

            // Define the area we are allowed to draw into
            IntPtr hRegion = region.GetHrgn(Graphics.FromHdc(hDC));
            Gdi32.SelectClipRgn(hDC, hRegion);

            Win32.RECT rectBox = new Win32.RECT();

            // Get the smallest rectangle that encloses region
            Gdi32.GetClipBox(hDC, ref rectBox);

            IntPtr brushHandler = GetHalfToneBrush();

            // Select brush into the device context
            IntPtr oldHandle = Gdi32.SelectObject(hDC, brushHandler);

            // Blit to screen using provided pattern brush and invert with existing screen contents
            Gdi32.PatBlt(hDC,
                rectBox.left,
                rectBox.top,
                rectBox.right - rectBox.left,
                rectBox.bottom - rectBox.top,
                (uint)Win32.RasterOperations.PATINVERT);

            // Put old handle back again
            Gdi32.SelectObject(hDC, oldHandle);

            // Reset the clipping region
            Gdi32.SelectClipRgn(hDC, IntPtr.Zero);

            Gdi32.DeleteObject(hRegion);

            // Must remember to release the HDC resource!
            User32.ReleaseDC(IntPtr.Zero, hDC);
        }
Exemple #2
0
 public static extern int GetClipBox(IntPtr hDC, ref Win32.RECT rectBox);
Exemple #3
0
 public static extern IntPtr CreateRectRgnIndirect(ref Win32.RECT rect);
Exemple #4
0
 public static extern bool InvalidateRect(IntPtr hWnd, ref RECT rect, bool erase);
Exemple #5
0
 public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
Exemple #6
0
 public static extern bool DrawFocusRect(IntPtr hWnd, ref RECT rect);