From 40dd779a6ead7ef755a5fef57d38acc31d0792bb Mon Sep 17 00:00:00 2001 From: Blake Hensley Date: Tue, 18 Jan 2022 02:22:45 -0500 Subject: [PATCH] Fix FlatStyle drawing of ComboBox (#6505) --- .../Forms/ComboBox.FlatComboAdapter.cs | 44 ------------------- .../src/System/Windows/Forms/ComboBox.cs | 2 - 2 files changed, 46 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs index fb6de19a28b..9a3c1ae5d29 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.FlatComboAdapter.cs @@ -4,8 +4,6 @@ using System.Drawing; using System.Windows.Forms.Layout; -using static Interop; -using static Interop.User32; namespace System.Windows.Forms { @@ -185,48 +183,6 @@ protected virtual Color GetPopupOuterBorderColor(ComboBox comboBox, bool focused protected virtual Color GetInnerBorderColor(ComboBox comboBox) => comboBox.Enabled ? comboBox.BackColor : SystemColors.Control; - - /// - /// This eliminates flicker by removing the pieces we're going to paint ourselves from the update region. - /// Note the UpdateRegionBox is the bounding box of the actual update region. This is here so we can - /// quickly eliminate rectangles that aren't in the update region. - /// - public unsafe void ValidateOwnerDrawRegions(ComboBox comboBox, Rectangle updateRegionBox) - { - if (comboBox is null) - { - return; - } - - Rectangle topOwnerDrawArea = new Rectangle(0, 0, comboBox.Width, _innerBorder.Top); - Rectangle bottomOwnerDrawArea = new Rectangle(0, _innerBorder.Bottom, comboBox.Width, comboBox.Height - _innerBorder.Bottom); - Rectangle leftOwnerDrawArea = new Rectangle(0, 0, _innerBorder.Left, comboBox.Height); - Rectangle rightOwnerDrawArea = new Rectangle(_innerBorder.Right, 0, comboBox.Width - _innerBorder.Right, comboBox.Height); - - if (topOwnerDrawArea.IntersectsWith(updateRegionBox)) - { - RECT validRect = new RECT(topOwnerDrawArea); - ValidateRect(comboBox, &validRect); - } - - if (bottomOwnerDrawArea.IntersectsWith(updateRegionBox)) - { - RECT validRect = new RECT(bottomOwnerDrawArea); - ValidateRect(comboBox, &validRect); - } - - if (leftOwnerDrawArea.IntersectsWith(updateRegionBox)) - { - RECT validRect = new RECT(leftOwnerDrawArea); - ValidateRect(comboBox, &validRect); - } - - if (rightOwnerDrawArea.IntersectsWith(updateRegionBox)) - { - RECT validRect = new RECT(rightOwnerDrawArea); - ValidateRect(comboBox, &validRect); - } - } } } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs index b7f72f8513a..769543c1528 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs @@ -3915,8 +3915,6 @@ protected override void WndProc(ref Message m) RECT updateRegionBoundingRect = default; Gdi32.GetRgnBox(windowRegion, ref updateRegionBoundingRect); - FlatComboBoxAdapter.ValidateOwnerDrawRegions(this, updateRegionBoundingRect); - // Call the base class to do its painting (with a clipped DC). bool useBeginPaint = m.WParamInternal == 0; using var paintScope = useBeginPaint ? new BeginPaintScope(Handle) : default;