Improve Message Box in WinForms
Fixes #12044
Proposed changes
- Style, localize Message Box and add some public API to use custom icon.
Screenshots
Before
After
Test methodology
Manually tested via scratch project.
Microsoft Reviewers: Open in CodeFlow
Codecov Report
:x: Patch coverage is 0% with 141 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 77.13902%. Comparing base (fd670ec) to head (454faa0).
Additional details and impacted files
@@ Coverage Diff @@
## main #13440 +/- ##
====================================================
+ Coverage 62.47359% 77.13902% +14.66543%
====================================================
Files 3262 3279 +17
Lines 644522 645458 +936
Branches 47630 47737 +107
====================================================
+ Hits 402656 497900 +95244
+ Misses 234702 143871 -90831
+ Partials 7164 3687 -3477
| Flag | Coverage Δ | |
|---|---|---|
| Debug | 77.13902% <0.00000%> (+14.66543%) |
:arrow_up: |
| integration | 18.97615% <0.00000%> (-0.01942%) |
:arrow_down: |
| production | 51.99527% <0.00000%> (+32.99970%) |
:arrow_up: |
| test | 97.40749% <ø> (ø) |
|
| unit | 49.42135% <0.00000%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Hey guys,
so, I am a bit confused. In the discussion to the issue, the sentiment seemed to be not taking any changes for the old MessageBox, let alone add new APIs to it.
So, it's not exactly clear to me, what we want to do here. We cannot change the API of the existing MessageBox, as it would break the world, almost literally.
But we will also not have an additional MessageBox, which would do essentially do the same as the old one. We said that we want the TaskDialog to move forward, and I am looking actively at what options we might have, to have that one adapted to dark mode.
Yes, it's not ideal that we do not have dark mode support for the native MessageBox-es as it is. And even if we did not touch their APIs - looking at the code, I am not entirely sure, if we want to take the risk of hijacking too many of the API calls (but @JeremyKuhne would have the final saying in this, anyway) as a principal approach.
The only way to get the old MessageBox display acceptable in dark mode would probably be, to completely reimplement it in WinForms based on what we're actually supporting in terms of dark mode support.
That's something I had considered, and I have actually a prototype for testing, and would bring TO a team meeting if time allows during the Preview 6-time frame. But even that is not really likely to make the bar.
We need to discuss internally at the next team meeting, and I will follow up, but I do not see a good chance this being taken.
Klaus
Hey guys,
so, I am a bit confused. In the discussion to the issue, the sentiment seemed to be not taking any changes for the old MessageBox, let alone add new APIs to it.
So, it's not exactly clear to me, what we want to do here. We cannot change the API of the existing MessageBox, as it would break the world, almost literally.
But we will also not have an additional MessageBox, which would do essentially do the same as the old one. We said that we want the TaskDialog to move forward, and I am looking actively at what options we might have, to have that one adapted to dark mode.
Yes, it's not ideal that we do not have dark mode support for the native MessageBox-es as it is. And even if we did not touch their APIs - looking at the code, I am not entirely sure, if we want to take the risk of hijacking too many of the API calls (but @JeremyKuhne would have the final saying in this, anyway) as a principal approach.
The only way to get the old MessageBox display acceptable in dark mode would probably be, to completely reimplement it in WinForms based on what we're actually supporting in terms of dark mode support.
That's something I had considered, and I have actually a prototype for testing, and would bring TO a team meeting if time allows during the Preview 6-time frame. But even that is not really likely to make the bar.
We need to discuss internally at the next team meeting, and I will follow up, but I do not see a good chance this being taken.
Klaus
I think installing a hook and uninstalling the hook inside of ShowCore is fine, but allowing one to be able to:
- customize the colors beyond just going into dark mode.
- customize the icon.
Are both beyond the scope of MessageBox.
However, hooking into it's WndProc to override it into dark mode should be alright as long as the person who opened this PR makes it to where that is not part of the public API surface (to ensure existing code does not break) while also allowing dark mode out-of-box when the developer enables dark mode in their application. The reason for this is that I see a way that this can be done as an implementation detail without exposing any new public API's.