private static WINDOWPLACEMENT GetPlacement(IntPtr windowHandle)
        {
            WINDOWPLACEMENT lpwndpl;

            UNSAFENATIVEMETHODS.GetWindowPlacement(windowHandle, out lpwndpl);
            return(lpwndpl);
        }
 private static void SetPlacement(IntPtr windowHandle, WINDOWPLACEMENT placement)
 {
     placement.Length  = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
     placement.Flags   = 0;
     placement.ShowCmd = placement.ShowCmd == SwShowminimized ? SwShownormal : placement.ShowCmd;
     UNSAFENATIVEMETHODS.SetWindowPlacement(windowHandle, ref placement);
 }
 private void UpdateDwmBorder()
 {
     if (WindowState == WindowState.Maximized)
     {
         noDwmBorder.Visibility = Visibility.Hidden;
     }
     else
     {
         bool flag1 = Environment.OSVersion.Version.Major >= 6 && !HardwareRenderingHelper.IsInSoftwareMode &&
                      DwmIsCompositionEnabled() && !SystemInformation.TerminalServerSession;
         uint pvParam = 0U;
         bool flag2   =
             UNSAFENATIVEMETHODS.SystemParametersInfo(SystemParametersInfoAction.SpiGetdropshadow, 0U,
                                                      ref pvParam, 0U) && (int)pvParam != 0;
         noDwmBorder.Visibility = ((flag1 && flag2 && !IsActive) ? Visibility.Hidden : Visibility.Visible);
     }
 }
        /// <summary>
        /// HWNDs the hook.
        /// </summary>
        /// <param name="hWnd">The h WND.</param>
        /// <param name="message">The message.</param>
        /// <param name="wParam">The w param.</param>
        /// <param name="lParam">The l param.</param>
        /// <param name="handled">if set to <c>true</c> [handled].</param>
        /// <returns></returns>
        private IntPtr HwndHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            IntPtr returnval = IntPtr.Zero;

            switch (message)
            {
            case WmNccalcsize:
                // Hides the border
                handled = true;
                break;

            case WmNcpaint:
                // Works for Windows Vista and higher
                if (isHardwareRenderingEnabled)
                {
                    var m = new MARGINS {
                        bottomHeight = 1, leftWidth = 1, rightWidth = 1, topHeight = 1
                    };
                    UNSAFENATIVEMETHODS.DwmExtendFrameIntoClientArea(mHwnd, ref m);
                }
                handled = true;
                break;

            case WmNcactivate:
                /* As per http://msdn.microsoft.com/en-us/library/ms632633(VS.85).aspx , "-1" lParam does not
                 * repaint the nonclient area to reflect the state change. */
                returnval = UNSAFENATIVEMETHODS.DefWindowProc(hWnd, message, wParam, new IntPtr(-1));
                handled   = true;
                break;

            case WmGetminmaxinfo:
                /* From Lester's Blog (thanks @aeoth):
                 * http://blogs.msdn.com/b/llobo/archive/2006/08/01/maximizing-window-_2800_with-windowstyle_3d00_none_2900_-considering-taskbar.aspx */
                UNSAFENATIVEMETHODS.WmGetMinMaxInfo(hWnd, lParam, minimumSize);
                handled = true;
                break;
            }

            return(returnval);
        }