private static Minmaxinfo AdjustWorkingAreaForAutoHide(IntPtr monitor, Minmaxinfo mmi)
        {
            var hwnd = NativeMethods.FindWindow("Shell_TrayWnd", null);
            var monitorWithTaskBar = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaulttonearest);

            if (!monitor.Equals(monitorWithTaskBar))
            {
                return(mmi);
            }
            var abd = new Appbardata();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = hwnd;
            NativeMethods.SHAppBarMessage((int)AbMsg.AbmGettaskbarpos, ref abd);
            var uEdge    = GetEdge(abd.rc);
            var autoHide = Convert.ToBoolean(NativeMethods.SHAppBarMessage((int)AbMsg.AbmGetstate, ref abd));

            if (!autoHide)
            {
                return(mmi);
            }

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

            case (int)AbEdge.AbeRight:
                mmi.ptMaxSize.X      -= 2;
                mmi.ptMaxTrackSize.X -= 2;
                break;

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

            case (int)AbEdge.AbeBottom:
                mmi.ptMaxSize.Y      -= 2;
                mmi.ptMaxTrackSize.Y -= 2;
                break;

            default:
                return(mmi);
            }
            return(mmi);
        }