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);
		}
        public static void DrawDragFrame(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
            Gdi32.SelectClipRgn(hDC, region.GetHrgn(Graphics.FromHdc(hDC)));

            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);

            // Must remember to release the HDC resource!
            User32.ReleaseDC(IntPtr.Zero, hDC);
        }
Exemple #3
0
 public static extern int GetClipBox(IntPtr hDC, ref Win32.RECT rectBox);
Exemple #4
0
 public static extern IntPtr CreateRectRgnIndirect(ref Win32.RECT rect);
Exemple #5
0
 public static extern bool InvalidateRect(IntPtr hWnd, ref RECT rect, bool erase);
Exemple #6
0
 public static extern bool DrawFocusRect(IntPtr hWnd, ref RECT rect);
Exemple #7
0
 public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
Exemple #8
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)Win32.Msgs.WM_NCCALCSIZE)
            {
                Win32.RECT rect = (Win32.RECT)m.GetLParam(typeof(Win32.RECT));
                m_sizeFrame = new Size(rect.right - rect.left, rect.bottom - rect.top);
                base.WndProc(ref m);
                rect.left   += BorderWidth;
                rect.right  -= BorderWidth;
                rect.top    += BorderWidth;
                rect.bottom -= BorderWidth;
                Marshal.StructureToPtr(rect, m.LParam, true);
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCPAINT)
            {
                if (BorderWidth <= 0)
                {
                    return;
                }

                IntPtr    hDC       = User32.GetWindowDC(m.HWnd);
                Graphics  g         = Graphics.FromHdc(hDC);
                Rectangle rectFrame = new Rectangle(0, 0, m_sizeFrame.Width, m_sizeFrame.Height);
                using (Region regionBorder = new Region(rectFrame))
                {
                    regionBorder.Xor(Rectangle.Inflate(rectFrame, -BorderWidth, -BorderWidth));
                    g.FillRegion(SystemBrushes.ControlDark, regionBorder);
                }
                User32.ReleaseDC(m.HWnd, hDC);
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_MOUSEACTIVATE)
            {
                if (!ContentWindow.FlagMouseActivate)
                {
                    ContentWindow.FlagMouseActivate = true;
                    base.WndProc(ref m);
                    ContentWindow.FlagMouseActivate = false;
                    ContentWindow.Activate();
                }
                else
                {
                    base.WndProc(ref m);
                }
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)
            {
                base.WndProc(ref m);

                HitTestResult hitTestResult = GetHitTest();
                if (hitTestResult.HitArea != HitTestArea.Caption)
                {
                    return;
                }

                if (DockHelper.IsDockStateAutoHide(DockState))
                {
                    DockManager.ActiveAutoHideContent = null;
                    return;
                }

                if (DockHelper.IsDockStateDocked(DockState) && ContentWindow.IsDockStateValid(DockState.Float))
                {
                    ContentWindow.VisibleState = DockState.Float;
                }
                else if (DockState == DockState.Float && ContentWindow.RestoreState != DockState.Unknown &&
                         ContentWindow.IsDockStateValid(ContentWindow.RestoreState))
                {
                    ContentWindow.VisibleState = ContentWindow.RestoreState;
                }

                return;
            }

            base.WndProc(ref m);
            return;
        }