diff --git a/Documents/Changelog/Changelog.md b/Documents/Changelog/Changelog.md index d7ad75042..7a8de3185 100644 --- a/Documents/Changelog/Changelog.md +++ b/Documents/Changelog/Changelog.md @@ -4,6 +4,7 @@ ## 2026-11-xx - Build 2611 (V110 Nightly) - November 2026 +* Resolved [#2914](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2914), White bar is shown in a `KryptonForm` Sizable without buttons and text * Implemented [#187](https://github.com/Krypton-Suite/Standard-Toolkit/issues/187), Can the Extended Kit Scrollbars be placed into standard and used by all controls that have scrollability? * Resolved [#2862](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2862), Form border resize flicker * Implemented [#595](https://github.com/Krypton-Suite/Standard-Toolkit/issues/595), Detachable Ribbons - Added ability to detach `KryptonRibbon` into a floating window with `AllowDetach` property, `Detach()` and `Reattach()` methods, and `RibbonDetached`/`RibbonReattached` events. See [Detachable Ribbons Documentation](Detachable-Ribbons-Feature.md) for comprehensive details. diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs index 9d88666fb..27eaeb591 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs @@ -2193,6 +2193,38 @@ protected override bool WindowChromeLeftMouseDown(Point windowPoint) return ret; } + /// + protected override bool OnWM_NCCALCSIZE(ref Message m) + { + // Does the LParam contain a RECT or an NCCALCSIZE_PARAMS + if (m.WParam != IntPtr.Zero) + { + // Get the border sizing needed around the client area + Padding borders = RealWindowBorders; + + // If caption should be hidden, set top border to 0 to prevent white band + if (ShouldHideCaption()) + { + borders = new Padding(borders.Left, 0, borders.Right, borders.Bottom); + } + + // Extract the Win32 NCCALCSIZE_PARAMS structure from LPARAM + PI.NCCALCSIZE_PARAMS calcsize = (PI.NCCALCSIZE_PARAMS)m.GetLParam(typeof(PI.NCCALCSIZE_PARAMS))!; + + // Reduce provided RECT by the borders + calcsize.rectProposed.left += borders.Left; + calcsize.rectProposed.top += borders.Top; + calcsize.rectProposed.right -= borders.Right; + calcsize.rectProposed.bottom -= borders.Bottom; + + // Put back the modified structure + Marshal.StructureToPtr(calcsize, m.LParam, false); + } + + // Message processed, do not pass onto base class for processing + return true; + } + protected override void OnMove(EventArgs e) { base.OnMove(e); @@ -2260,6 +2292,30 @@ private void OnFormBorderStyleChanged() return null; } + /// + /// Determines if the caption area should be hidden (no text, no icon, no control box, no visible buttons). + /// + /// True if caption should be hidden; otherwise false. + private bool ShouldHideCaption() + { + // Check if there are any visible buttons + bool hasVisibleButtons = false; + foreach (ButtonSpecView bsv in _buttonManager.ButtonSpecViews) + { + if (bsv.ViewCenter.Visible && bsv.ViewButton.Enabled) + { + hasVisibleButtons = true; + break; + } + } + + // Hide caption if no control box, no text, no icon, and no visible buttons + return !ControlBox + && string.IsNullOrEmpty(GetShortText()) + && GetDefinedIcon() == null + && !hasVisibleButtons; + } + private void SetHeaderStyle(ViewDrawDocker drawDocker, PaletteTripleMetricRedirect palette, HeaderStyle style) @@ -2369,15 +2425,29 @@ private bool CheckViewLayout() } // Update the heading to enforce a fixed Material-like caption height when Material renderer is active - if (Renderer is RenderMaterial) + bool shouldHideCaption = ShouldHideCaption(); + + if (shouldHideCaption) { - const int materialCaptionHeight = 44; // px - _headingFixedSize.FixedSize = new Size(materialCaptionHeight, materialCaptionHeight); + // Hide the caption area when there's nothing to display + _headingFixedSize.FixedSize = Size.Empty; + _headingFixedSize.Visible = false; } else { - Padding windowBorders = RealWindowBorders; - _headingFixedSize.FixedSize = new Size(windowBorders.Top, windowBorders.Top); + // Ensure the heading is visible + _headingFixedSize.Visible = true; + + if (Renderer is RenderMaterial) + { + const int materialCaptionHeight = 44; // px + _headingFixedSize.FixedSize = new Size(materialCaptionHeight, materialCaptionHeight); + } + else + { + Padding windowBorders = RealWindowBorders; + _headingFixedSize.FixedSize = new Size(windowBorders.Top, windowBorders.Top); + } } // A change in window state since last time requires a layout diff --git a/Source/Krypton Components/TestForm/Bug2914Test.Designer.cs b/Source/Krypton Components/TestForm/Bug2914Test.Designer.cs new file mode 100644 index 000000000..0d9965344 --- /dev/null +++ b/Source/Krypton Components/TestForm/Bug2914Test.Designer.cs @@ -0,0 +1,49 @@ +namespace TestForm +{ + partial class Bug2914Test + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Bug2914Test + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.CloseBox = false; + this.ControlBox = false; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Bug2914Test"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/Bug2914Test.cs b/Source/Krypton Components/TestForm/Bug2914Test.cs new file mode 100644 index 000000000..1a7a34732 --- /dev/null +++ b/Source/Krypton Components/TestForm/Bug2914Test.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace TestForm; + +public partial class Bug2914Test : KryptonForm +{ + public Bug2914Test() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/Bug2914Test.resx b/Source/Krypton Components/TestForm/Bug2914Test.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/Source/Krypton Components/TestForm/Bug2914Test.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/StartScreen.cs b/Source/Krypton Components/TestForm/StartScreen.cs index f42cef1d8..d5340d93d 100644 --- a/Source/Krypton Components/TestForm/StartScreen.cs +++ b/Source/Krypton Components/TestForm/StartScreen.cs @@ -61,6 +61,7 @@ private void AddButtons() CreateButton("Accessibility Test (UIA Providers)", "Comprehensive demo and test for UIA Provider implementation (Issue #762). Tests all 10 controls with accessibility support, organized by category with detailed results.", typeof(AccessibilityTest)); CreateButton("Badge Test", "Comprehensive badge functionality demonstration for KryptonButton and KryptonCheckButton.", typeof(ButtonBadgeTest)); CreateButton("Buttons Test", "All the buttons you want to test.", typeof(ButtonsTest)); + CreateButton("Bug 2914 Test", "Tests the fix for 2914.", typeof(Bug2914Test)); CreateButton("BugReportingTool", "Easily report bugs with this tool.", typeof(BugReportingDialogTest)); CreateButton("Code Editor", "Native code editor with syntax highlighting, line numbering, code folding, and auto-completion.", typeof(CodeEditorTest)); CreateButton("Countdown Button", "Comprehensive demonstration of KryptonCountdownButton features with customizable duration, format, and enable-at-zero options.", typeof(CountdownButtonTest));