private static void InvalidateFormCaption(Control containerControl) { int height = SystemInformation.Border3DSize.Height + SystemInformation.CaptionHeight; WinApi.RECT r = new WinApi.RECT(0, -height, containerControl.Width, height); WinApi.RedrawWindow(containerControl.Handle, ref r, IntPtr.Zero, WinApi.RedrawWindowFlags.RDW_INVALIDATE | WinApi.RedrawWindowFlags.RDW_FRAME | WinApi.RedrawWindowFlags.RDW_UPDATENOW); }
protected virtual Rectangle GetClientRectangle(Rectangle r) { if (this.WindowState == FormWindowState.Maximized && !this.IsGlassEnabled) { WinApi.RECT rect = new WinApi.RECT(0, 0, 100, 100); CreateParams params1 = this.CreateParams; WinApi.AdjustWindowRectEx(ref rect, params1.Style, false, params1.ExStyle); Rectangle wr = rect.ToRectangle(); int borderWidth = Math.Abs(wr.X); int borderHeight = wr.Bottom - 100; int formBorderSize = 3; int formBorderSizeHorizontal = m_DisplayRectangleReductionHorizontal + 1 - 3; m_NonClientOffset.X = (borderWidth - formBorderSizeHorizontal); m_NonClientOffset.Y = (borderWidth - formBorderSize - 1); r.X += m_NonClientOffset.X; r.Width -= (borderWidth * 2 - formBorderSizeHorizontal * 2 - 1); r.Height -= (borderWidth * 2 - formBorderSize * 2 - 1); r.Y += m_NonClientOffset.Y; Screen scr = Screen.FromHandle(this.Handle); if (r.Height > scr.Bounds.Height && scr.Primary) r.Height = scr.Bounds.Height; } else { m_NonClientOffset = Point.Empty; if (IsGlassEnabled) { NonClientInfo nci = GetNonClientInfo(); int borderWidth = nci.LeftBorder; // SystemInformation.FrameBorderSize.Width /* *NativeFunctions.BorderMultiplierFactor*/; int borderHeight = nci.BottomBorder; // SystemInformation.FrameBorderSize.Height /* * NativeFunctions.BorderMultiplierFactor*/; //if (FormBorderStyle == FormBorderStyle.Fixed3D) //{ // borderWidth = SystemInformation.Border3DSize.Width + SystemInformation.FixedFrameBorderSize.Width; // borderHeight = SystemInformation.Border3DSize.Height + SystemInformation.FixedFrameBorderSize.Height; //} //else if (FormBorderStyle == FormBorderStyle.FixedDialog) //{ // borderWidth = SystemInformation.FixedFrameBorderSize.Width; // borderHeight = SystemInformation.FixedFrameBorderSize.Height; //} //else if (FormBorderStyle == FormBorderStyle.FixedSingle) //{ // borderWidth = 1; // borderHeight = 1; //} r.X += borderWidth; r.Width -= borderWidth * 2; r.Height -= borderHeight; if (WindowState == FormWindowState.Maximized || WinApi.IsZoomed(this.Handle)) { Screen scr = Screen.FromHandle(this.Handle); if (r.Height > scr.Bounds.Height && scr.Primary) r.Height = scr.Bounds.Height + borderHeight - 2; } } else if (BarFunctions.IsVista && !BarFunctions.IsWindows7) r.Height--; } return r; }
protected virtual void AdjustBounds(ref int width, ref int height, BoundsSpecified specified) { WinApi.RECT rect = new WinApi.RECT(0, 0, width, height); CreateParams params1 = this.CreateParams; WinApi.AdjustWindowRectEx(ref rect, params1.Style, false, params1.ExStyle); NonClientInfo nci = GetNonClientInfo(); if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height) { height -= (rect.Height - height); if (IsGlassEnabled) { height += nci.BottomBorder; } } if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width && !IsGlassEnabled) width -= (rect.Width - width); }
internal NonClientInfo GetNonClientInfo() { WinApi.RECT rect = new WinApi.RECT(0, 0, 200, 200); CreateParams params1 = this.CreateParams; WinApi.AdjustWindowRectEx(ref rect, params1.Style, false, params1.ExStyle); NonClientInfo n = new NonClientInfo(); n.CaptionTotalHeight = Math.Abs(rect.Top); n.BottomBorder = rect.Height - 200 - n.CaptionTotalHeight; n.LeftBorder = Math.Abs(rect.Left); n.RightBorder = rect.Width - 200 - n.LeftBorder; if (FormBorderStyle == FormBorderStyle.FixedSingle) { n.BottomBorder = 1; n.LeftBorder = 1; n.RightBorder = 1; } return n; }