Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark mode/Visual Styles (VB Only) fix #11907

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

KlausLoeffelmann
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann commented Aug 17, 2024

  • Fixes issue where in Visual Basic the "classic" Visual Styles are no longer get set. (This is a breaking change, since in VB the classic Visual Styles are no longer set, even if they are enabled in the VS App Framework Property Pages.)
    NOTE: This has nothing to do with the originally considered VisualStylesMode Experimental feature in the dark mode context.

  • Fixes issue where instead of the FormCaptionTextColorChanged event the FormCaptionBackColorChanged event is raised (This is not a breaking change, since these are completely new events.)

Fixes #11898.
Fixes #11897.
Fixes #11895.
Fixes #11910.

@KlausLoeffelmann KlausLoeffelmann self-assigned this Aug 17, 2024
Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 11.11111% with 48 lines in your changes missing coverage. Please review.

Project coverage is 75.01587%. Comparing base (5a2d6d2) to head (3aeafc3).
Report is 10 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #11907         +/-   ##
===================================================
- Coverage   75.01833%   75.01587%   -0.00246%     
===================================================
  Files           3047        3047                 
  Lines         631591      631621         +30     
  Branches       46764       46770          +6     
===================================================
+ Hits          473809      473816          +7     
- Misses        154420      154440         +20     
- Partials        3362        3365          +3     
Flag Coverage Δ
Debug 75.01587% <11.11111%> (-0.00246%) ⬇️
integration 17.93497% <11.11111%> (+0.00056%) ⬆️
production 48.12799% <11.11111%> (-0.00263%) ⬇️
test 97.01653% <ø> (ø)
unit 45.15198% <7.40741%> (-0.00407%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Aug 17, 2024
@@ -2428,14 +2440,16 @@ private unsafe void SetFormCornerPreferenceInternal(FormCornerPreference cornerP
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = DiagnosticIDs.UrlFormat)]
Copy link

@memoarfaa memoarfaa Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlausLoeffelmann
I see this function need to be in some Controls not only in Form So that we can benefit from it to the maximum extent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function can be applied to all popup

this function can be applied to all popup Windows

like Menus ,Tooltips, ...........

Non round example

2024-08-18_04-42-29.mp4

Round example

2024-08-18_04-51-13.mp4

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what do you mean "this function can be applied..."
When I see the video clips, I see I few things I have questions about. Like the dark Tab Control. How is that implemented/tuned?

The rounded Buttons look cool (and also the tool tips and other elements I see).
Is this done by custom rendering or did you apply the same Win32 API to it?

Keep in mind:
VisualStylesMode was a concept I came up with primarily driven by accessibility, actually somewhat late in the development cycle (around end of April/begin of May I think I only had the first prototype which I did as a proof of concept first in my spare time) to complement the dark mode feature in terms of contrast issues we saw, and in general to address an upcoming regulatory issue where we need bigger "real estate" for clicking "landing spots" for controls. So, the teeny-tiny Up-Down-Buttons from NumericUpDown or DomainUpDown are very extreme examples for that. They are just an accessibility nightmare IMO. The non-styleble MonthCalendar with its tiny date numbers is another example. And TextBox (TextBoxBase) itself is yet another one, because we cannot adjust its Padding: In 96 dpi without a border, it got only a height of 16 pixels, if I remember correctly. And that's just not good enough in the context of HighDPI-Monitors and mindful accessibility. So - "styling" improvements should have those things in mind. The animated CheckBox looks arguably cooler than the old one as a side effect, alright: But: It has that bigger landing spot and is better recognizable. We need to have a valid argument in that regard to think about improvements in style or real-estate.

Everything that goes beyond that becomes Theming, and that's where we (WinForms Team) all agreed, is a line we cannot cross. Our third parties have those things already in place, and they do an extremely good job with that.

Copy link

@memoarfaa memoarfaa Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what do you mean "this function can be applied..." When I see the video clips, I see I few things I have questions about. Like the dark Tab Control. How is that implemented/tuned?

this is implemented by paint on Wm_ Paint but there is multiple solution for the Tab Control see #11953.

The rounded Buttons look cool (and also the tool tips and other elements I see). Is this done by custom rendering or did you apply the same Win32 API to it?

The tool tips and pop up menus use DWM_WINDOW_CORNER_PREFERENCE and any Window has WS_POPUP can use it

#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
            if (SystemInformation.HighContrast)
            {
                PInvoke.SetWindowTheme(HWND, string.Empty, string.Empty);
            }
            else if (Application.IsDarkModeEnabled && !_isBalloon)
            {
                DWM_WINDOW_CORNER_PREFERENCE round = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND;
                PInvoke.DwmSetWindowAttribute(HWND, DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE, &round, sizeof(DWM_WINDOW_CORNER_PREFERENCE));
                PInvoke.SendMessage(HWND, PInvoke.TTM_SETWINDOWTHEME, default, "DarkMode_Explorer");
            }

#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
        }

the remains elements is use Uxtheme Win32 API and its Documented.

Everything that goes beyond that becomes Theming, and that's where we (WinForms Team) all agreed, is a line we cannot cross. Our third parties have those things already in place, and they do an extremely good job with that.

may me not one line but multiple lines

@KlausLoeffelmann KlausLoeffelmann marked this pull request as ready for review August 18, 2024 22:10
@KlausLoeffelmann KlausLoeffelmann requested a review from a team as a code owner August 18, 2024 22:10
@dotnet-policy-service dotnet-policy-service bot removed the draft draft PR label Aug 19, 2024
lonitra
lonitra previously approved these changes Aug 19, 2024
Copy link
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KlausLoeffelmann KlausLoeffelmann merged commit c993d33 into dotnet:main Aug 19, 2024
8 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0 Preview1 milestone Aug 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.