Exemplo n.º 1
0
        private UIElementBorderWidths GetBorderWidth()
        {
            UIElementBorderWidths result = default(UIElementBorderWidths);

            if (IsManagerEnabled)
            {
                switch (manager.BorderStyle)
                {
                case MdiClientBorderStyle.Inset:
                {
                    int num9  = result.Bottom = 2;
                    int num11 = result.Top = num9;
                    int num14 = result.Left = (result.Right = num11);
                    break;
                }

                case MdiClientBorderStyle.Solid:
                {
                    int num2 = result.Bottom = 1;
                    int num4 = result.Top = num2;
                    int num7 = result.Left = (result.Right = num4);
                    break;
                }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        protected override void WndProc(ref Message m)
        {
            JwMdiManager ultraTabbedMdiManager = _manager;

            if (ultraTabbedMdiManager == null)
            {
                base.WndProc(ref m);
                return;
            }
            switch (m.Msg)
            {
            case (int)WinApi.Messages.WM_MDIRESTORE:
            case (int)WinApi.Messages.WM_MDIMAXIMIZE:
            case (int)WinApi.Messages.WM_MDITILE:
            case (int)WinApi.Messages.WM_MDICASCADE:
            case (int)WinApi.Messages.WM_MDIICONARRANGE:
                //if (ultraTabbedMdiManager.Enabled)
                //{
                m.Result = IntPtr.Zero;
                return;

            //}
            //break;
            case (int)WinApi.Messages.WM_MDINEXT:
            {
                Form mdiChild = null;
                if (m.WParam == IntPtr.Zero)
                {
                    Control control = Control.FromChildHandle(base.Handle);
                    if (control is Form)
                    {
                        mdiChild = ((Form)control).ActiveMdiChild;
                    }
                }
                else
                {
                    mdiChild = (Control.FromHandle(m.WParam) as Form);
                }
                bool forward    = m.LParam == IntPtr.Zero;
                Form nextWindow = GetNextWindow(mdiChild, forward);
                if (ultraTabbedMdiManager.TabNavigationMode == MdiTabNavigationMode.VisibleOrder)
                {
                    nextWindow?.Activate();
                    m.Result = IntPtr.Zero;
                    return;
                }
                if (!SendActivationNotification(nextWindow))
                {
                    break;
                }
                if (AllowMdiChildActivate(nextWindow))
                {
                    ultraTabbedMdiManager.SubclasserActivatingMdiChild = true;
                    try
                    {
                        base.WndProc(ref m);
                    }
                    finally
                    {
                        ultraTabbedMdiManager.SubclasserActivatingMdiChild = false;
                        ultraTabbedMdiManager.AfterSubclasserFormActivation(nextWindow);
                    }
                }
                else
                {
                    m.Result = IntPtr.Zero;
                }
                return;
            }

            case (int)WinApi.Messages.WM_MDIACTIVATE:
            {
                Form form = Control.FromHandle(m.WParam) as Form;
                if (!SendActivationNotification(form))
                {
                    break;
                }
                if (AllowMdiChildActivate(form))
                {
                    ultraTabbedMdiManager.SubclasserActivatingMdiChild = true;
                    try
                    {
                        base.WndProc(ref m);
                    }
                    finally
                    {
                        ultraTabbedMdiManager.SubclasserActivatingMdiChild = false;
                        ultraTabbedMdiManager.AfterSubclasserFormActivation(form);
                    }
                }
                else
                {
                    m.Result = IntPtr.Zero;
                }
                return;
            }

            case (int)WinApi.Messages.WM_NCPAINT:
            {
                base.WndProc(ref m);
                if (!IsManagerEnabled)
                {
                    return;
                }
                IntPtr   intPtr   = IntPtr.Zero;
                Graphics graphics = null;
                IntPtr   hWnd     = m.HWnd;
                try
                {
                    Rectangle rectangle = new Rectangle(Point.Empty, DisplayRectangle.Size);
                    if (m.WParam == IntPtr.Zero || m.WParam.ToInt64() == 1)
                    {
                        intPtr = WinApi.GetWindowDC(hWnd);
                    }
                    else
                    {
                        intPtr = WinApi.GetDCEx(hWnd, m.WParam, 129);
                        if (intPtr == IntPtr.Zero)
                        {
                            intPtr = WinApi.GetWindowDC(m.HWnd);
                        }
                    }
                    if (intPtr != IntPtr.Zero)
                    {
                        SecurityPermission securityPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                        securityPermission.Assert();
                        graphics = Graphics.FromHdc(intPtr);
                        CodeAccessPermission.RevertAssert();
                        DrawBorder(graphics, rectangle, rectangle);
                        m.Result = IntPtr.Zero;
                    }
                }
                finally
                {
                    graphics?.Dispose();
                    if (intPtr != IntPtr.Zero)
                    {
                        WinApi.ReleaseDC(hWnd, intPtr);
                    }
                }
                return;
            }

            case (int)WinApi.Messages.WM_NCCALCSIZE:
                if (IsManagerEnabled && m.WParam.ToInt64() == 1)
                {
                    NativeWindowMethods.NCCALCSIZE_PARAMS nCCALCSIZE_PARAMS = (NativeWindowMethods.NCCALCSIZE_PARAMS)m.GetLParam(typeof(NativeWindowMethods.NCCALCSIZE_PARAMS));
                    UIElementBorderWidths borderWidth = GetBorderWidth();
                    displayRect = nCCALCSIZE_PARAMS.rectProposed.Rect;
                    nCCALCSIZE_PARAMS.rectProposed.left   += borderWidth.Left;
                    nCCALCSIZE_PARAMS.rectProposed.right  -= borderWidth.Right;
                    nCCALCSIZE_PARAMS.rectProposed.top    += borderWidth.Top;
                    nCCALCSIZE_PARAMS.rectProposed.bottom -= borderWidth.Bottom;
                    Marshal.StructureToPtr(nCCALCSIZE_PARAMS, m.LParam, fDeleteOld: false);
                }
                break;

            case (int)WinApi.Messages.WM_ERASEBKGND:
                base.WndProc(ref m);
                if (IsManagerEnabled)
                {
                    m.Result = new IntPtr(1);
                }
                return;

            case (int)WinApi.Messages.WM_PARENTNOTIFY:
                if ((m.WParam.ToInt32() & 0xFFFF) == 1)
                {
                    _manager.MdiClientCreateNotification();
                }
                break;
            }
            base.WndProc(ref m);
        }