Beispiel #1
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;
        }