示例#1
0
        private void OnWMGetMinMaxInfo(ref Message m)
        {
            Telerik.WinControls.NativeMethods.MINMAXINFO structure = (Telerik.WinControls.NativeMethods.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(Telerik.WinControls.NativeMethods.MINMAXINFO));
            if (this.Form.IsMdiChild)
            {
                structure.ptMaxTrackSize.x = Math.Max(structure.ptMaxTrackSize.x, structure.ptMaxSize.x);
            }
            else if (!this.Form.IsMdiChild && this.IsMaximized && !DWMAPI.IsCompositionEnabled)
            {
                structure.ptMaxTrackSize.y = this.GetMaximumFormHeightAccordingToCurrentScreen();
                if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1)
                {
                    Screen screen = Screen.FromControl((Control)this.Form);
                    if (screen != null)
                    {
                        structure.ptMaxPosition.y = screen.WorkingArea.Y - SystemInformation.FrameBorderSize.Height;
                    }
                }
            }
            structure.ptMinTrackSize.x = SystemInformation.MinimumWindowSize.Width;
            structure.ptMinTrackSize.y = this.ClientMargin.Vertical;
            MinMaxInfo minMaxInfo = new MinMaxInfo();

            minMaxInfo.MaxPosition  = new Point(structure.ptMaxPosition.x, structure.ptMaxPosition.y);
            minMaxInfo.MaxTrackSize = new Size(structure.ptMaxTrackSize.x, structure.ptMaxTrackSize.y);
            minMaxInfo.MinTrackSize = new Size(structure.ptMinTrackSize.x, structure.ptMinTrackSize.y);
            minMaxInfo.MaxSize      = new Size(structure.ptMaxSize.x, structure.ptMaxSize.y);
            minMaxInfo.SizeReserved = new Size(structure.ptReserved.x, structure.ptReserved.y);
            this.OnGetMinMaxInfo(minMaxInfo);
            structure.ptMaxPosition.x  = minMaxInfo.MaxPosition.X;
            structure.ptMaxPosition.y  = minMaxInfo.MaxPosition.Y;
            structure.ptMaxTrackSize.x = minMaxInfo.MaxTrackSize.Width;
            structure.ptMaxTrackSize.y = minMaxInfo.MaxTrackSize.Height;
            structure.ptMinTrackSize.x = minMaxInfo.MinTrackSize.Width;
            structure.ptMinTrackSize.y = minMaxInfo.MinTrackSize.Height;
            structure.ptMaxSize.x      = minMaxInfo.MaxSize.Width;
            structure.ptMaxSize.y      = minMaxInfo.MaxSize.Height;
            structure.ptReserved.x     = minMaxInfo.SizeReserved.Width;
            structure.ptReserved.y     = minMaxInfo.SizeReserved.Height;
            Marshal.StructureToPtr((object)structure, m.LParam, true);
            this.CallBaseWndProc(ref m);
        }
示例#2
0
        protected override void WndProc(ref Message m)
        {
            if (this.shape != null || this.IsMdiContainer)
            {
                switch (m.Msg)
                {
                case 131:
                    m.Result = IntPtr.Zero;
                    return;

                case 133:
                    m.Result = IntPtr.Zero;
                    return;

                case 134:
                    this.active = Convert.ToBoolean(m.WParam.ToInt32());
                    this.Invalidate();
                    m.Result = (IntPtr)1;
                    return;

                case 174:
                case 175:
                    m.Result = IntPtr.Zero;
                    return;
                }
            }
            if (m.Msg == 736)
            {
                if (!RadControl.EnableDpiScaling)
                {
                    return;
                }
                this.oldDpi     = this.currentDpi;
                this.currentDpi = (int)(short)(int)m.WParam;
                if (this.oldDpi != this.currentDpi)
                {
                    if (this.isMoving)
                    {
                        this.shouldScale = true;
                    }
                    else
                    {
                        this.HandleDpiChanged();
                    }
                }
            }
            switch (m.Msg)
            {
            case 36:
                Telerik.WinControls.NativeMethods.MINMAXINFO structure = (Telerik.WinControls.NativeMethods.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(Telerik.WinControls.NativeMethods.MINMAXINFO));
                if (this.Parent == null)
                {
                    Screen    screen      = Screen.FromControl((Control)this);
                    Rectangle workingArea = screen.WorkingArea;
                    Rectangle bounds      = screen.Bounds;
                    structure.ptMaxSize.x     = workingArea.Width;
                    structure.ptMaxSize.y     = workingArea.Height;
                    structure.ptMaxPosition.x = workingArea.X - bounds.X;
                    structure.ptMaxPosition.y = workingArea.Y - bounds.Y;
                    Marshal.StructureToPtr((object)structure, m.LParam, false);
                }
                base.WndProc(ref m);
                return;

            case 71:
                if (this.IsMdiContainer)
                {
                    this.OnLayout(new LayoutEventArgs((Control)this, "Bounds"));
                    break;
                }
                break;

            case 132:
                if (this.FormBorderStyle == FormBorderStyle.None && this.AllowResize)
                {
                    Point client = this.PointToClient(new Point(m.LParam.ToInt32()));
                    m.Result = (IntPtr)this.GetHitTest(client);
                    return;
                }
                break;

            case 787:
                this.WmTaskBarMenu();
                break;
            }
            base.WndProc(ref m);
        }