private static WindowWndProcHandler.TaskbarLocation GetTaskbarPosition()
 {
     WindowWndProcHandler.TaskbarLocation taskbarLocation = WindowWndProcHandler.TaskbarLocation.None;
     WindowWndProcHandler.APPBARDATA      data            = new WindowWndProcHandler.APPBARDATA();
     data.cbSize = Marshal.SizeOf((object)data);
     if (NativeMethods.SHAppBarMessage(5, ref data) == IntPtr.Zero)
     {
         return(taskbarLocation);
     }
     if (data.rc.Left == data.rc.Top)
     {
         if (data.rc.Right < data.rc.Bottom)
         {
             taskbarLocation = WindowWndProcHandler.TaskbarLocation.Left;
         }
         if (data.rc.Right > data.rc.Bottom)
         {
             taskbarLocation = WindowWndProcHandler.TaskbarLocation.Top;
         }
     }
     if (data.rc.Left > data.rc.Top)
     {
         taskbarLocation = WindowWndProcHandler.TaskbarLocation.Right;
     }
     if (data.rc.Left < data.rc.Top)
     {
         taskbarLocation = WindowWndProcHandler.TaskbarLocation.Bottom;
     }
     return(taskbarLocation);
 }
        private void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            WindowWndProcHandler.MINMAXINFO structure = (WindowWndProcHandler.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(WindowWndProcHandler.MINMAXINFO));
            IntPtr hmonitor = NativeMethods.MonitorFromWindow(hwnd, 1);

            if (hmonitor != IntPtr.Zero)
            {
                WindowWndProcHandler.MONITORINFOEX info = new WindowWndProcHandler.MONITORINFOEX()
                {
                    cbSize = Marshal.SizeOf(typeof(MONITORINFO))
                };
                NativeMethods.GetMonitorInfo(hmonitor, info);
                IntereopRect rcWork    = info.rcWork;
                IntereopRect rcMonitor = info.rcMonitor;
                WindowWndProcHandler.TaskbarLocation taskbarPosition = WindowWndProcHandler.GetTaskbarPosition();
                if (!this.mWindowInstance.mIsFullScreen)
                {
                    structure.ptMaxPosition.X = Math.Abs(rcWork.Left - rcMonitor.Left);
                    structure.ptMaxPosition.Y = Math.Abs(rcWork.Top - rcMonitor.Top);
                    structure.ptMaxSize.X     = Math.Abs(rcWork.Width);
                    structure.ptMaxSize.Y     = Math.Abs(rcWork.Height);
                    if (rcWork == rcMonitor)
                    {
                        switch (taskbarPosition)
                        {
                        case WindowWndProcHandler.TaskbarLocation.Left:
                            structure.ptMaxPosition.X += 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Top:
                            structure.ptMaxPosition.Y += 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Right:
                            structure.ptMaxSize.X -= 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Bottom:
                            structure.ptMaxSize.Y -= 2;
                            break;
                        }
                    }
                }
                else
                {
                    structure.ptMaxPosition.X = 0;
                    structure.ptMaxPosition.Y = 0;
                    structure.ptMaxSize.X     = Math.Abs(rcMonitor.Width);
                    structure.ptMaxSize.Y     = Math.Abs(rcMonitor.Height);
                }
                structure.ptMaxTrackSize.X = structure.ptMaxSize.X;
                structure.ptMaxTrackSize.Y = structure.ptMaxSize.Y;
            }
            Marshal.StructureToPtr((object)structure, lParam, true);
        }