Ejemplo n.º 1
0
        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
            int        MONITOR_DEFAULTTONEAREST = 0x00000002;

            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);

                RECT rcWorkArea    = monitorInfo.rcWork;
                RECT rcMonitorArea = monitorInfo.rcMonitor;

                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);

                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);

                mmi.ptMinTrackSize.x = (int)System.Windows.SystemParameters.WorkArea.Width;
                mmi.ptMinTrackSize.y = (int)System.Windows.SystemParameters.WorkArea.Height;
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Ejemplo n.º 2
0
        internal static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area
            // of the correct monitor.
            Int32 MONITOR_DEFAULTTONEAREST = 0x00000002;

            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);

                RECT rcWorkArea    = monitorInfo.m_rcWork;
                RECT rcMonitorArea = monitorInfo.m_rcMonitor;

                mmi.m_ptMaxPosition.m_x = Math.Abs(rcWorkArea.m_left - rcMonitorArea.m_left);
                mmi.m_ptMaxPosition.m_y = Math.Abs(rcWorkArea.m_top - rcMonitorArea.m_top);

                mmi.m_ptMaxSize.m_x = Math.Abs(rcWorkArea.m_right - rcWorkArea.m_left);
                mmi.m_ptMaxSize.m_y = Math.Abs(rcWorkArea.m_bottom - rcWorkArea.m_top);
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Ejemplo n.º 3
0
        private static IntPtr CompatibilityMaximizedNoneWindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
            case 0x0024:                        // WM_GETMINMAXINFO
                MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                // Adjust the maximized size and position
                // to fit the work area of the correct monitor
                // int MONITOR_DEFAULTTONEAREST = 0x00000002;
                var monitor = MonitorFromWindow(hwnd, 0x00000002);
                if (monitor != IntPtr.Zero)
                {
                    MONITORINFO monitorInfo = new MONITORINFO();
                    GetMonitorInfo(monitor, monitorInfo);
                    RECT rcWorkArea    = monitorInfo.rcWork;
                    RECT rcMonitorArea = monitorInfo.rcMonitor;
                    mmi.ptMaxPosition.x =
                        Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                    mmi.ptMaxPosition.y =
                        Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                    mmi.ptMaxSize.x =
                        Math.Abs(rcWorkArea.right - rcWorkArea.left);
                    mmi.ptMaxSize.y =
                        Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
                }
                Marshal.StructureToPtr(mmi, lParam, true);
                handled = true;
                break;
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 4
0
        private void WmGetMinMaxInfo(ref Message m)
        {
            MINMAXINFO minmax =
                (MINMAXINFO)Marshal.PtrToStructure(
                    m.LParam, typeof(MINMAXINFO));

            if (MaximumSize != Size.Empty)
            {
                minmax.maxTrackSize = MaximumSize;
            }
            else
            {
                Rectangle rect = Screen.GetWorkingArea(this);
                int       h    = this.FormBorderStyle == FormBorderStyle.None ? 0 : -1;
                minmax.maxPosition = new Point(
                    rect.X,
                    rect.Y);
                minmax.maxTrackSize = new Size(
                    rect.Width,
                    rect.Height + h);
            }

            if (MinimumSize != Size.Empty)
            {
                minmax.minTrackSize = MinimumSize;
            }
            Marshal.StructureToPtr(minmax, m.LParam, false);
        }
 IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     switch (msg)
     {
     case 0x0024:
         MINMAXINFO mmi     = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
         IntPtr     monitor = MonitorFromWindow(hwnd, 0x00000002 /*MONITOR_DEFAULTTONEAREST*/);
         if (monitor != IntPtr.Zero)
         {
             MONITORINFO monitorInfo = new MONITORINFO {
             };
             GetMonitorInfo(monitor, monitorInfo);
             RECT rcWorkArea    = monitorInfo.rcWork;
             RECT rcMonitorArea = monitorInfo.rcMonitor;
             mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
             mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
             mmi.ptMaxSize.x     = Math.Abs(rcWorkArea.right - rcWorkArea.left);
             mmi.ptMaxSize.y     = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
             if (!CachedMinTrackSize.Equals(mmi.ptMinTrackSize) || CachedMinHeight != MinHeight && CachedMinWidth != MinWidth)
             {
                 mmi.ptMinTrackSize.x = (int)((CachedMinWidth = MinWidth) * WindowCompositionTarget.TransformToDevice.M11);
                 mmi.ptMinTrackSize.y = (int)((CachedMinHeight = MinHeight) * WindowCompositionTarget.TransformToDevice.M22);
                 CachedMinTrackSize   = mmi.ptMinTrackSize;
             }
         }
         Marshal.StructureToPtr(mmi, lParam, true);
         handled = true;
         break;
     }
     return(IntPtr.Zero);
 }
        public IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_GETMINMAXINFO)
            {
                // We need to tell the system what our size should be when maximized. Otherwise it will cover the whole screen,
                // including the task bar.
                MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                // Adjust the maximized size and position to fit the work area of the correct monitor
                IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

                if (monitor != IntPtr.Zero)
                {
                    MONITORINFO monitorInfo = new MONITORINFO();
                    monitorInfo.cbSize = Marshal.SizeOf(typeof(MONITORINFO));
                    GetMonitorInfo(monitor, ref monitorInfo);
                    RECT rcWorkArea    = monitorInfo.rcWork;
                    RECT rcMonitorArea = monitorInfo.rcMonitor;
                    mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                    mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                    mmi.ptMaxSize.X     = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                    mmi.ptMaxSize.Y     = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
                }

                Marshal.StructureToPtr(mmi, lParam, true);
            }

            return(IntPtr.Zero);
        }
Ejemplo n.º 7
0
        private void WmGetMinMaxInfo(ref Message m)
        {
            MINMAXINFO minmax = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));

            if (MaximumSize != Size.Empty)
            {
                minmax.maxTrackSize = MaximumSize;
            }
            else
            {
                Rectangle rect = Screen.GetWorkingArea(this);
                minmax.maxPosition = new Point(
                    Math.Abs(rect.X),
                    Math.Abs(rect.Y));
                minmax.maxTrackSize = new Size(
                    rect.Width,
                    rect.Height);
            }

            if (MinimumSize != Size.Empty)
            {
                minmax.minTrackSize = MinimumSize;
            }
            else
            {
                minmax.minTrackSize = new Size(150, 39);
            }

            Marshal.StructureToPtr(minmax, m.LParam, false);
        }
Ejemplo n.º 8
0
        private void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
            // Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST = 0x00000002;

            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != System.IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT   rcWorkArea    = monitorInfo.rcWork;
                RECT   rcMonitorArea = monitorInfo.rcMonitor;
                double scale         = rcMonitorArea.Width / SystemParameters.VirtualScreenWidth;
                mmi.ptMaxPosition.x  = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y  = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                mmi.ptMaxSize.x      = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y      = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
                mmi.ptMinTrackSize.x = (int)Math.Floor(ActiveWindow.MinWidth * scale);
                mmi.ptMinTrackSize.y = (int)Math.Floor(ActiveWindow.MinHeight * scale);
                //if (ActiveWindow.MaxHeight != Double.PositiveInfinity)
                //{
                //    mmi.ptMaxTrackSize.y = (int)Math.Floor(ActiveWindow.MaxHeight * scale);
                //}
                //if (ActiveWindow.MaxWidth != Double.PositiveInfinity)
                //{
                //    mmi.ptMaxTrackSize.x = (int)Math.Floor(ActiveWindow.MaxWidth * scale);
                //}
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST = 0x00000002;

            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != System.IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT rcWorkArea    = monitorInfo.rcWork;
                RECT rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.x  = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y  = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                mmi.ptMaxSize.x      = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y      = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
                mmi.ptMinTrackSize.x = 800;
                mmi.ptMinTrackSize.y = 600;
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Ejemplo n.º 10
0
        private void WmGetMinMaxInfo(ref Message m)
        {
            MINMAXINFO structure = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));

            if (this.MaximumSize != System.Drawing.Size.Empty)
            {
                structure.maxTrackSize = this.MaximumSize;
            }
            else
            {
                Rectangle workingArea = Screen.GetWorkingArea(this);
                int       num         = (this.FormBorderStyle == System.Windows.Forms.FormBorderStyle.None) ? 0 : -1;
                structure.maxPosition  = new System.Drawing.Point(workingArea.X, workingArea.Y);
                structure.maxTrackSize = new System.Drawing.Size(workingArea.Width, workingArea.Height + num);
            }
            //if (this.MinimumSize != System.Drawing.Size.Empty)
            //{
            //    structure.minTrackSize = this.MinimumSize;
            //}
            //else
            //{
            //    this.GetDefaultMinTrackSize();
            //    structure.minTrackSize = new System.Drawing.Size((((this.AllButtonWidth(true) + this.ControlBoxOffset.X) + SystemInformation.SmallIconSize.Width) + (this.BorderPadding.Left * 2)) + 3, this.CaptionHeight);
            //}
            Marshal.StructureToPtr(structure, m.LParam, false);
        }
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            POINT lMousePosition;

            GetCursorPos(out lMousePosition);

            IntPtr      lPrimaryScreen     = MonitorFromPoint(new POINT(0, 0), MonitorOptions.MONITOR_DEFAULTTOPRIMARY);
            MONITORINFO lPrimaryScreenInfo = new MONITORINFO();

            if (GetMonitorInfo(lPrimaryScreen, lPrimaryScreenInfo) == false)
            {
                return;
            }

            IntPtr lCurrentScreen = MonitorFromPoint(lMousePosition, MonitorOptions.MONITOR_DEFAULTTONEAREST);

            MINMAXINFO lMmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            if (lPrimaryScreen.Equals(lCurrentScreen) == true)
            {
                lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcWork.Left;
                lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcWork.Top;
                lMmi.ptMaxSize.X     = lPrimaryScreenInfo.rcWork.Right - lPrimaryScreenInfo.rcWork.Left;
                lMmi.ptMaxSize.Y     = lPrimaryScreenInfo.rcWork.Bottom - lPrimaryScreenInfo.rcWork.Top;
            }
            else
            {
                lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcMonitor.Left;
                lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcMonitor.Top;
                lMmi.ptMaxSize.X     = lPrimaryScreenInfo.rcMonitor.Right - lPrimaryScreenInfo.rcMonitor.Left;
                lMmi.ptMaxSize.Y     = lPrimaryScreenInfo.rcMonitor.Bottom - lPrimaryScreenInfo.rcMonitor.Top;
            }

            Marshal.StructureToPtr(lMmi, lParam, true);
        }
Ejemplo n.º 12
0
        private IntPtr WndProcHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_GETMINMAXINFO)
            {
                MINMAXINFO mmi     = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
                IntPtr     monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
                if (monitor != IntPtr.Zero)
                {
                    MONITORINFO monitorInfo = new MONITORINFO();
                    monitorInfo.cbSize = Marshal.SizeOf(typeof(MONITORINFO));
                    GetMonitorInfo(monitor, ref monitorInfo);
                    RECT workArea    = monitorInfo.rcWork;
                    RECT monitorArea = monitorInfo.rcMonitor;
                    mmi.ptMaxPosition.X = workArea.Left - monitorArea.Left - 1;
                    mmi.ptMaxPosition.Y = workArea.Top - monitorArea.Top - 1;
                    mmi.ptMaxSize.X     = workArea.Right - workArea.Left + 2;
                    mmi.ptMaxSize.Y     = workArea.Bottom - workArea.Top + 2;
                    mmi.ptMaxTrackSize  = mmi.ptMaxSize;
                    handled             = true;
                }

                Marshal.StructureToPtr(mmi, lParam, true);
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 13
0
        public static IntPtr SetMaxSizeHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // All windows messages (msg) can be found here
            // https://docs.microsoft.com/de-de/windows/win32/winmsg/window-notifications
            if (msg == WM_GETMINMAXINFO)
            {
                // We need to tell the system what our size should be when maximized. Otherwise it will
                // cover the whole screen, including the task bar.
                MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                // Adjust the maximized size and position to fit the work area of the correct monitor
                IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

                if (monitor != IntPtr.Zero)
                {
                    MONITORINFO monitorInfo = default;
                    monitorInfo.cbSize = Marshal.SizeOf(typeof(MONITORINFO));
                    GetMonitorInfo(monitor, ref monitorInfo);
                    RECT rcWorkArea    = monitorInfo.rcWork;
                    RECT rcMonitorArea = monitorInfo.rcMonitor;
                    mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                    mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                    mmi.ptMaxSize.X     = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                    mmi.ptMaxSize.Y     = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
                }

                Marshal.StructureToPtr(mmi, lParam, true);
            }

            return(IntPtr.Zero);
        }
Ejemplo n.º 14
0
        private bool OnGetMinMaxInfo(ref Message m)
        {
            Control hostedControl = GetHostedControl();

            if (hostedControl != null)
            {
                MINMAXINFO minmax = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));

                // Maximum size.
                if (hostedControl.MaximumSize.Width != 0)
                {
                    minmax.maxTrackSize.Width = hostedControl.MaximumSize.Width;
                }
                if (hostedControl.MaximumSize.Height != 0)
                {
                    minmax.maxTrackSize.Height = hostedControl.MaximumSize.Height;
                }

                // Minimum size.
                minmax.minTrackSize = new Size(32, 32);
                if (hostedControl.MinimumSize.Width > minmax.minTrackSize.Width)
                {
                    minmax.minTrackSize.Width = hostedControl.MinimumSize.Width;
                }
                if (hostedControl.MinimumSize.Height > minmax.minTrackSize.Height)
                {
                    minmax.minTrackSize.Height = hostedControl.MinimumSize.Height;
                }

                Marshal.StructureToPtr(minmax, m.LParam, false);
            }
            return(true);
        }
Ejemplo n.º 15
0
        public static IntPtr HookProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_GETMINMAXINFO)
            {
                MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

                if (monitor != IntPtr.Zero)
                {
                    MONITORINFO monitorInfo = new MONITORINFO
                    {
                        cbSize = Marshal.SizeOf(typeof(MONITORINFO))
                    };
                    GetMonitorInfo(monitor, ref monitorInfo);
                    RECT rcWorkArea    = monitorInfo.rcWork;
                    RECT rcMonitorArea = monitorInfo.rcMonitor;
                    mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                    mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                    mmi.ptMaxSize.X     = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                    mmi.ptMaxSize.Y     = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
                }

                Marshal.StructureToPtr(mmi, lParam, true);
            }

            return(IntPtr.Zero);
        }
Ejemplo n.º 16
0
        void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            // MINMAXINFO structure
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            //拿到最靠近当前软件的显示器
            IntPtr hMonitor = NativeMethods.MonitorFromWindow(Handle, NativeConstants.MONITOR_DEFAULTTONEAREST);

            // Get monitor info   显示屏
            MONITORINFOEX monitorInfo = new MONITORINFOEX();

            monitorInfo.cbSize = Marshal.SizeOf(monitorInfo);
            NativeMethods.GetMonitorInfo(new HandleRef(this, hMonitor), monitorInfo);

            // Convert working area
            RECT workingArea = monitorInfo.rcWork;

            //设置最大化的时候的坐标
            mmi.ptMaxPosition.x = 0; // workingArea.left;
            mmi.ptMaxPosition.y = 0; // workingArea.top;

            if (source == null)
            {
                throw new Exception("Cannot get HwndSource instance.");
            }
            if (source.CompositionTarget == null)
            {
                throw new Exception("Cannot get HwndTarget instance.");
            }

            Matrix matrix = source.CompositionTarget.TransformToDevice;

            Point dpiIndenpendentTrackingSize = matrix.Transform(new Point(
                                                                     this.MinWidth,
                                                                     this.MinHeight));

            if (FullScreen)
            {
                Point dpiSize = matrix.Transform(new Point(
                                                     SystemParameters.PrimaryScreenWidth,
                                                     SystemParameters.PrimaryScreenHeight
                                                     ));

                mmi.ptMaxSize.x = (int)dpiSize.X;
                mmi.ptMaxSize.y = (int)dpiSize.Y;
            }
            else
            {
                //设置窗口最大化的尺寸
                mmi.ptMaxSize.x = workingArea.right - workingArea.left;
                mmi.ptMaxSize.y = workingArea.bottom;
            }

            //设置最小跟踪大小
            mmi.ptMinTrackSize.x = (int)dpiIndenpendentTrackingSize.X;
            mmi.ptMinTrackSize.y = (int)dpiIndenpendentTrackingSize.Y;

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Ejemplo n.º 17
0
        private bool OnGetMinMaxInfo(ref Message m)
        {
            MINMAXINFO minmax = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));

            minmax.maxTrackSize = this.MaximumSize;
            minmax.minTrackSize = this.MinimumSize;
            Marshal.StructureToPtr(minmax, m.LParam, false);
            return(true);
        }
Ejemplo n.º 18
0
        protected override void WndProc(ref Message m)
        {
            const int WM_GETMINMAXINFO = 0x24;
            const int WM_HOTKEY        = 0x0312;

            switch (m.Msg)
            {
            case WM_GETMINMAXINFO:
                MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                mmi.ptMinTrackSize.x = this.Size.Width;
                mmi.ptMinTrackSize.y = this.Size.Height;
                Marshal.StructureToPtr(mmi, m.LParam, true);
                break;

            case WM_HOTKEY:
                switch (m.WParam.ToInt32())
                {
                case 100:            //按下的是 Alt+F5
                    IntPtr activeWindow     = GetActiveWindow();
                    IntPtr foregroundWindow = GetForegroundWindow();
                    if (activeWindow != IntPtr.Zero && activeWindow == foregroundWindow)
                    {
                        RefreshBtn_Click(null, null);                 //此处填写快捷键响应代码
                    }
                    break;

                case 101:            //按下的是 Alt+F5
                    IntPtr activeWindow2     = GetActiveWindow();
                    IntPtr foregroundWindow2 = GetForegroundWindow();
                    if (activeWindow2 != IntPtr.Zero && activeWindow2 == foregroundWindow2)
                    {
                        if (timerMouseClick.Enabled)
                        {
                            this.Text = this.Text.Substring(0, this.Text.LastIndexOf(" - 已开启鼠标连点,间隔:"));
                            timerMouseClick.Enabled = false;                 //此处填写快捷键响应代码
                        }
                        else
                        {
                            this.Text = this.Text + " - 已开启鼠标连点,间隔:" + this.mouseInterval;
                            timerMouseClick.Enabled = true;
                        }
                    }
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }

            base.WndProc(ref m);
        }
Ejemplo n.º 19
0
    static void WmGetMinMaxInfo(IntPtr lParam)
    {
        MINMAXINFO mmi = new MINMAXINFO();

        mmi.ptMinTrackSize.x = 100101;
        mmi.ptMinTrackSize.y = 102103;
        mmi.ptMaxTrackSize.x = 200201;
        mmi.ptMaxTrackSize.y = 202203;

        Marshal.StructureToPtr(mmi, lParam, true);
    }
Ejemplo n.º 20
0
        private static void WmGetMinMaxInfo(IntPtr hWnd, IntPtr lParam)
        {
            RECT winRect;

            GetWindowRect(new HandleRef(null, hWnd), out winRect);

            POINT winPoint = new POINT(winRect.Left, winRect.Top);

            // Get primary monitor info.
            IntPtr      lCurrentScreen     = MonitorFromPoint(winPoint, MonitorOptions.MONITOR_DEFAULTTONEAREST);
            MONITORINFO lCurrentScreenInfo = new MONITORINFO();

            // Get taskbar info
            Taskbar     taskbarInfo        = new Taskbar();
            MONITORINFO lTaskBarScreenInfo = new MONITORINFO();


            int left = 0, top = 0;
            int right  = Math.Abs(lCurrentScreenInfo.rcWork.Right - lCurrentScreenInfo.rcWork.Left);
            int bottom = Math.Abs(lCurrentScreenInfo.rcWork.Bottom - lCurrentScreenInfo.rcWork.Top);

            if (taskbarInfo.AutoHide)
            {
                // Reserve space for taskbar to get mouse focus
                switch (taskbarInfo.Position)
                {
                case TaskbarPosition.Bottom:
                    bottom -= 2;
                    break;

                case TaskbarPosition.Left:
                    left += 2;
                    break;

                case TaskbarPosition.Right:
                    right -= 2;
                    break;

                case TaskbarPosition.Top:
                    top += 2;
                    break;
                }
            }

            MINMAXINFO lMmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            lMmi.ptMaxPosition.X = left;
            lMmi.ptMaxPosition.Y = top;
            lMmi.ptMaxSize.X     = right;
            lMmi.ptMaxSize.Y     = bottom;

            Marshal.StructureToPtr(lMmi, lParam, true);
        }
Ejemplo n.º 21
0
        private void HandleMinMaxInfo(IntPtr lParam)
        {
            // overridden so max size = normal max + resize border (for when resizing content window to max size without maximizing)
            var thick = TranslateToPixels(BorderThickness);

            MINMAXINFO para = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
            var        orig = para.ptMaxTrackSize;

            orig.x += (int)(thick.Left + thick.Right);
            orig.y += (int)(thick.Top + thick.Bottom);
            para.ptMaxTrackSize = orig;
            Marshal.StructureToPtr(para, lParam, true);
        }
Ejemplo n.º 22
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch ((WM)msg)
            {
            case WM.MOUSEACTIVATE:
            {
                handled = true;
                return(new IntPtr(3));
            }

            case WM.LBUTTONDOWN:
            {
                if (!IsHitTestVisible)
                {
                    break;
                }

                //Point ptScreen = new Point((int)lParam & 0xFFFF, ((int)lParam >> 16) & 0xFFFF);
                Point ptScreen = GetScreenPosition(lParam);
                NativeMethods.PostMessage(new WindowInteropHelper(Owner).Handle,
                                          (uint)WM.NCLBUTTONDOWN, (IntPtr)getHitTestValue(ptScreen),
                                          IntPtr.Zero);
            }
            break;

            case WM.GETMINMAXINFO:
            {
                MINMAXINFO obj = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                if (obj.ptMaxSize.x > 0)
                {
                    obj.ptMaxSize.x          = obj.ptMaxSize.y =
                        obj.ptMaxTrackSize.x = obj.ptMaxTrackSize.y = int.MaxValue;
                    Marshal.StructureToPtr(obj, lParam, true);
                }
            }
            break;

            case WM.NCHITTEST:
            {
                //Point ptScreen = new Point((int)lParam & 0xFFFF, ((int)lParam >> 16) & 0xFFFF);
                Point ptScreen = GetScreenPosition(lParam);
                Cursor = GetCursor(PointFromScreen(ptScreen));
            }
            break;
            }

            return(IntPtr.Zero);
        }
Ejemplo n.º 23
0
        private MINMAXINFO GetMinMaxInfo(IntPtr hwnd, MINMAXINFO mmi)
        {
            // Adjust the maximized size and position to fit the work area of the correct monitor
            var monitor = UnsafeNativeMethods.MonitorFromWindow(hwnd, Constants.MONITOR_DEFAULTTONEAREST);

            if (monitor == IntPtr.Zero)
            {
                return(mmi);
            }

            var monitorInfo = new MONITORINFO();

            UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);
            var rcWorkArea    = monitorInfo.rcWork;
            var rcMonitorArea = monitorInfo.rcMonitor;

            Debug.WriteLine("Monitor-Info");
            Debug.WriteLine(string.Format("Work: {0}", rcWorkArea));
            Debug.WriteLine(string.Format("Mon : {0}", rcMonitorArea));

            Debug.WriteLine(string.Format("Before: {0}", mmi));

            mmi.ptMaxPosition.X = rcWorkArea.left;
            mmi.ptMaxPosition.Y = rcWorkArea.top;

            var ignoreTaskBar = this.IgnoreTaskBar();

            var x         = ignoreTaskBar ? monitorInfo.rcMonitor.left : monitorInfo.rcWork.left;
            var y         = ignoreTaskBar ? monitorInfo.rcMonitor.top : monitorInfo.rcWork.top;
            var maxWidth  = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.right - x) : Math.Abs(monitorInfo.rcWork.right - x);
            var maxHeight = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.bottom - y) : Math.Abs(monitorInfo.rcWork.bottom - y);

            var maxWindowWidth  = double.IsPositiveInfinity(this.window.MaxWidth) ? maxWidth : (int)this.window.MaxWidth;
            var maxWindowHeight = double.IsPositiveInfinity(this.window.MaxHeight) ? maxHeight : (int)this.window.MaxHeight;

            mmi.ptMaxSize.X = Math.Min(maxWidth, maxWindowWidth);
            mmi.ptMaxSize.Y = Math.Min(maxHeight, maxWindowHeight);

            if (!ignoreTaskBar)
            {
                mmi.ptMaxTrackSize.X = mmi.ptMaxSize.X;
                mmi.ptMaxTrackSize.Y = mmi.ptMaxSize.Y;
                mmi = AdjustWorkingAreaForAutoHide(monitor, mmi);
            }

            Debug.WriteLine(string.Format("After: {0}", mmi));

            return(mmi);
        }
Ejemplo n.º 24
0
 protected override void WndProc(ref Message m)
 {
     switch (m.Msg)
     {
     case WM_GETMINMAXINFO:
         MINMAXINFO mmi = (MINMAXINFO)System.Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));
         mmi.ptMaxSize.X     = this.Width;
         mmi.ptMaxSize.Y     = this.Height;
         mmi.ptMaxPosition.X = this.Location.X;
         mmi.ptMaxPosition.Y = this.Location.Y;
         System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true);
         break;
     }
     base.WndProc(ref m);
 }
        /// <summary>
        /// Creates and populates the MINMAXINFO structure for a maximized window.
        /// Puts the structure into memory address given by lParam.
        /// Only used to process a WM_GETMINMAXINFO message.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="lParam">The lParam.</param>
        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            // Get the MINMAXINFO structure from memory location given by lParam
            MINMAXINFO mmi =
                (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Get the monitor that overlaps the window or the nearest
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero)
            {
                // Get monitor information
                MONITORINFO monitorInfo = new MONITORINFO();
                monitorInfo.Size = Marshal.SizeOf(typeof(MONITORINFO));
                GetMonitorInfo(monitor, ref monitorInfo);

                // The display monitor rectangle.
                // If the monitor is not the primary display monitor,
                // some of the rectangle's coordinates may be negative values
                RECT rcMonitorArea = monitorInfo.WorkArea;

                // Get window information
                WINDOWINFO windowInfo = new WINDOWINFO();
                windowInfo.Size = (UInt32)(Marshal.SizeOf(typeof(WINDOWINFO)));
                GetWindowInfo(hwnd, ref windowInfo);
                int borderWidth  = (int)windowInfo.WindowBordersWidth;
                int borderHeight = (int)windowInfo.WindowBordersHeight;

                // Set the dimensions of the window in maximized state
                mmi.MaxPosition.X = -borderWidth;
                mmi.MaxPosition.Y = -borderHeight;
                mmi.MaxSize.X     =
                    rcMonitorArea.Right - rcMonitorArea.Left + 2 * borderWidth;
                mmi.MaxSize.Y =
                    rcMonitorArea.Bottom - rcMonitorArea.Top + 2 * borderHeight;

                // Set minimum and maximum size
                // to the size of the window in maximized state
                mmi.MinTrackSize.X = mmi.MaxSize.X;
                mmi.MinTrackSize.Y = mmi.MaxSize.Y;
                mmi.MaxTrackSize.X = mmi.MaxSize.X;
                mmi.MaxTrackSize.Y = mmi.MaxSize.Y;
            }

            // Copy the structure to memory location specified by lParam.
            // This concludes processing of WM_GETMINMAXINFO.
            Marshal.StructureToPtr(mmi, lParam, true);
        }
 protected override void WndProc(ref Message m)
 {
     base.WndProc(ref m);
     if (m.Msg == WM_GETMINMAXINFO)
     {
         MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
         mmi.ptMinTrackSize.x = this.szFullScreen.Width;
         mmi.ptMinTrackSize.y = this.szFullScreen.Height;
         //mmi.ptMaxSize.x = int.MaxValue;// this.MaximumSize.Width;
         //mmi.ptMaxSize.y = int.MaxValue; // this.MaximumSize.Height;
         //mmi.ptMaxTrackSize.x = int.MaxValue; // this.MaximumSize.Width;
         //mmi.ptMaxTrackSize.y = int.MaxValue; // this.MaximumSize.Height;
         System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true);
         //m.Result = (IntPtr)0;
     }
 }
Ejemplo n.º 27
0
    public unsafe static int Main()
    {
        MINMAXINFO mmi  = new MINMAXINFO();
        IntPtr     pmmi = Marshal.AllocHGlobal(Marshal.SizeOf(mmi));

        WmGetMinMaxInfo(pmmi);
        mmi = (MINMAXINFO)Marshal.PtrToStructure(pmmi, typeof(MINMAXINFO));
        bool valid = mmi.ptMinTrackSize.x == 100101 && mmi.ptMinTrackSize.y == 102103 && mmi.ptMaxTrackSize.x == 200201 && mmi.ptMaxTrackSize.y == 202203;

        if (!valid)
        {
            Console.WriteLine($"Got {mmi.ptMinTrackSize}, expected {{100101, 102103}}");
            Console.WriteLine($"Got {mmi.ptMaxTrackSize}, expected {{200201, 202203}}");
        }
        return(valid ? 100 : -1);
    }
Ejemplo n.º 28
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_GETMINMAXINFO)
            {
                this.MaximumSize = SystemInformation.WorkingArea.Size;
                MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                mmi.ptMinTrackSize.x = this.MinimumSize.Width;
                mmi.ptMinTrackSize.y = this.MinimumSize.Height;
                if (this.MaximumSize.Width != 0 || this.MaximumSize.Height != 0)
                {
                    mmi.ptMaxTrackSize.x = this.MaximumSize.Width;
                    mmi.ptMaxTrackSize.y = this.MaximumSize.Height;
                }
                //-------------------------
                int        aaa  = 0x00000005;
                APPBARDATA pdat = new APPBARDATA();
                SHAppBarMessage(aaa, ref pdat);

                if (pdat.uEdge == 0) //左
                {
                    mmi.ptMaxPosition.x = Screen.PrimaryScreen.Bounds.Width - SystemInformation.WorkingArea.Width;
                    mmi.ptMaxPosition.y = 0;
                }
                else if (pdat.uEdge == 1) //上
                {
                    mmi.ptMaxPosition.x = 0;
                    mmi.ptMaxPosition.y = Screen.PrimaryScreen.Bounds.Height - SystemInformation.WorkingArea.Height;
                }
                else if (pdat.uEdge == 2) //右
                {
                    mmi.ptMaxPosition.x = 0;
                    mmi.ptMaxPosition.y = 0;
                }
                else if (pdat.uEdge == 3) //下
                {
                    mmi.ptMaxPosition.x = 0;
                    mmi.ptMaxPosition.y = 0;
                }

                System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true);
            }
        }
Ejemplo n.º 29
0
        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            try
            {
                POINT lMousePosition;
                GetCursorPos(out lMousePosition);

                IntPtr      lPrimaryScreen     = MonitorFromPoint(new POINT(0, 0), MonitorOptions.MONITOR_DEFAULTTOPRIMARY);
                MONITORINFO lPrimaryScreenInfo = new MONITORINFO();
                if (GetMonitorInfo(lPrimaryScreen, lPrimaryScreenInfo) == false)
                {
                    return;
                }

                IntPtr lCurrentScreen = MonitorFromPoint(lMousePosition, MonitorOptions.MONITOR_DEFAULTTONEAREST);

                MINMAXINFO lMmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

                RECT rcWorkArea    = lPrimaryScreenInfo.rcWork;
                RECT rcMonitorArea = lPrimaryScreenInfo.rcMonitor;


                if (lPrimaryScreen.Equals(lCurrentScreen))
                {
                    lMmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                    lMmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                    lMmi.ptMaxSize.X     = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                    lMmi.ptMaxSize.Y     = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
                }
                else
                {
                    lMmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                    lMmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                    lMmi.ptMaxSize.X     = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                    lMmi.ptMaxSize.Y     = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
                }

                Marshal.StructureToPtr(lMmi, lParam, true);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 30
0
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_GETMINMAXINFO)
            {
                MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                mmi.ptMinTrackSize.x = this.MinimumSize.Width;
                mmi.ptMinTrackSize.y = this.MinimumSize.Height;
                if (this.MaximumSize.Width != 0 || this.MaximumSize.Height != 0)
                {
                    mmi.ptMaxTrackSize.x = this.MaximumSize.Width;
                    mmi.ptMaxTrackSize.y = this.MaximumSize.Height;
                }
                mmi.ptMaxPosition.x = 0;
                mmi.ptMaxPosition.y = 0;

                System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true);
            }
        }
Ejemplo n.º 31
0
        private static MINMAXINFO AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, MINMAXINFO mmi)
        {
            IntPtr hwnd = FindWindow("Shell_TrayWnd", null);
            if (hwnd == null) return mmi;
            IntPtr monitorWithTaskbarOnIt = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
            if (!monitorContainingApplication.Equals(monitorWithTaskbarOnIt)) return mmi;
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd = hwnd;
            SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd);
            int uEdge = GetEdge(abd.rc);
            bool autoHide = System.Convert.ToBoolean(SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd));

            if (!autoHide) return mmi;

            switch (uEdge)
            {
                case (int)ABEdge.ABE_LEFT:
                    mmi.ptMaxPosition.x += 2;
                    mmi.ptMaxTrackSize.x -= 2;
                    mmi.ptMaxSize.x -= 2;
                    break;
                case (int)ABEdge.ABE_RIGHT:
                    mmi.ptMaxSize.x -= 2;
                    mmi.ptMaxTrackSize.x -= 2;
                    break;
                case (int)ABEdge.ABE_TOP:
                    mmi.ptMaxPosition.y += 2;
                    mmi.ptMaxTrackSize.y -= 2;
                    mmi.ptMaxSize.y -= 2;
                    break;
                case (int)ABEdge.ABE_BOTTOM:
                    mmi.ptMaxSize.y -= 2;
                    mmi.ptMaxTrackSize.y -= 2;
                    break;
                default:
                    return mmi;
            }
            return mmi;
        }
Ejemplo n.º 32
0
		public static extern Int32 CopyMemory2(Int32 pDst,ref MINMAXINFO pSrc,Int32 ByteLen);
Ejemplo n.º 33
0
        /// <summary>
        /// This method handles the window size if the taskbar is set to auto-hide.
        /// </summary>
        private static MINMAXINFO AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, MINMAXINFO mmi)
        {
            var hwnd = UnsafeNativeMethods.FindWindow("Shell_TrayWnd", null);
            var monitorWithTaskbarOnIt = UnsafeNativeMethods.MonitorFromWindow(hwnd, Constants.MONITOR_DEFAULTTONEAREST);

            if (monitorContainingApplication.Equals(monitorWithTaskbarOnIt) == false)
            {
                return mmi;
            }

            var abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd = hwnd;
            UnsafeNativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd);
            var uEdge = GetEdge(abd.rc);
            var autoHide = UnsafeNativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd) == new IntPtr(1);

            if (!autoHide)
            {
                return mmi;
            }

            switch (uEdge)
            {
                case (int)ABEdge.ABE_LEFT:
                    mmi.ptMaxPosition.X += 2;
                    mmi.ptMaxTrackSize.X -= 2;
                    mmi.ptMaxSize.X -= 2;
                    break;

                case (int)ABEdge.ABE_RIGHT:
                    mmi.ptMaxSize.X -= 2;
                    mmi.ptMaxTrackSize.X -= 2;
                    break;

                case (int)ABEdge.ABE_TOP:
                    mmi.ptMaxPosition.Y += 2;
                    mmi.ptMaxTrackSize.Y -= 2;
                    mmi.ptMaxSize.Y -= 2;
                    break;

                case (int)ABEdge.ABE_BOTTOM:
                    mmi.ptMaxSize.Y -= 2;
                    mmi.ptMaxTrackSize.Y -= 2;
                    break;

                default:
                    return mmi;
            }

            return mmi;
        }
Ejemplo n.º 34
0
        private MINMAXINFO GetMinMaxInfo(IntPtr hwnd, MINMAXINFO mmi)
        {
            // Adjust the maximized size and position to fit the work area of the correct monitor
            var monitor = UnsafeNativeMethods.MonitorFromWindow(hwnd, Constants.MONITOR_DEFAULTTONEAREST);

            if (monitor == IntPtr.Zero)
            {
                return mmi;
            }

            var monitorInfo = new MONITORINFO();
            UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);
            var rcWorkArea = monitorInfo.rcWork;
            var rcMonitorArea = monitorInfo.rcMonitor;

            Debug.WriteLine("Monitor-Info");
            Debug.WriteLine(string.Format("Work: {0}", rcWorkArea));
            Debug.WriteLine(string.Format("Mon : {0}", rcMonitorArea));

            Debug.WriteLine(string.Format("Before: {0}", mmi));

            mmi.ptMaxPosition.X = rcWorkArea.left;
            mmi.ptMaxPosition.Y = rcWorkArea.top;

            var ignoreTaskBar = this.IgnoreTaskBar();

            var x = ignoreTaskBar ? monitorInfo.rcMonitor.left : monitorInfo.rcWork.left;
            var y = ignoreTaskBar ? monitorInfo.rcMonitor.top : monitorInfo.rcWork.top;
            mmi.ptMaxSize.X = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.right - x) : Math.Abs(monitorInfo.rcWork.right - x);
            mmi.ptMaxSize.Y = ignoreTaskBar ? Math.Abs(monitorInfo.rcMonitor.bottom - y) : Math.Abs(monitorInfo.rcWork.bottom - y);

            if (!ignoreTaskBar)
            {
                mmi.ptMaxTrackSize.X = mmi.ptMaxSize.X;
                mmi.ptMaxTrackSize.Y = mmi.ptMaxSize.Y;
                mmi = AdjustWorkingAreaForAutoHide(monitor, mmi);
            }

            Debug.WriteLine(string.Format("After: {0}", mmi));

            return mmi;
        }
 public static extern IntPtr SendMessageTimeout(
     NativeMethods.HWND hwnd, int Msg, IntPtr wParam, ref MINMAXINFO lParam, int flags, int uTimeout, out IntPtr pResult );