Fix issue 14094: After reducing the form width, clicking the ToolStrip options triggers a Win32Exception error#14244
Open
SimonZhao888 wants to merge 7 commits intodotnet:mainfrom
Open
Fix issue 14094: After reducing the form width, clicking the ToolStrip options triggers a Win32Exception error#14244SimonZhao888 wants to merge 7 commits intodotnet:mainfrom
SimonZhao888 wants to merge 7 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Win32Exception when ToolStripControlHost-hosted controls (e.g., ToolStripComboBox/ToolStripProgressBar) move into the overflow drop-down after the form is narrowed, by ensuring the ToolStrip parent has a handle before reparenting hosted controls.
Changes:
- Update
ToolStripControlHost.SyncControlParent()to create the ToolStrip parent handle when the hosted control handle already exists. - Add a regression test covering moving hosted controls with existing handles into the overflow drop-down without throwing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripControlHost.cs | Ensures the ToolStrip parent handle exists before adding the hosted control to the ToolStrip’s control collection. |
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs | Adds a regression test intended to reproduce/guard against the overflow reparenting Win32Exception scenario. |
src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripControlHostTests.cs
Show resolved
Hide resolved
LeafShi1
reviewed
Jan 26, 2026
added 2 commits
January 27, 2026 13:41
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14244 +/- ##
===================================================
+ Coverage 77.17712% 77.17980% +0.00267%
===================================================
Files 3279 3279
Lines 645129 645161 +32
Branches 47728 47730 +2
===================================================
+ Hits 497892 497934 +42
+ Misses 143544 143528 -16
- Partials 3693 3699 +6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14094
Proposed changes
Customer Impact
Regression?
Risk
-Min
Screenshots
Before
After
Bug14094.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow