-
Notifications
You must be signed in to change notification settings - Fork 980
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
[Regression] Form title bars are the wrong color (app with its own custom dark theming) #12014
Comments
I'm not sure why this was tagged as |
@rickbrew may be confusion here is due to topic subject? I think we need something like "[regression] .... " |
I guess my point is that this isn't something where I'm trying to use the new Dark Mode experimental features. If that were the case, I'd expect it to have some bugs that could be fixed later. This is a situation where I'm explicitly not using it, but it's still breaking my app in a way that prevents me from migrating to .NET 9. |
@KlausLoeffelmann @JeremyKuhne @elachlan @merriemcgaw @Tanya-Solyanik |
Sorry this got tagged incorrectly. Looking at it now. |
…de a choice This creates havoc for existing dark mode implementors. Fixes dotnet#12014
…de a choice This creates havoc for existing dark mode implementors. Fixes #12014
.NET version
.NET 9.0.0-rc.1.24421.1 (downloaded at https://github.com/dotnet/sdk/blob/main/documentation/package-table.md)
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes, it works fine in .NET 8. This only happens when I change the target framework to 9.
Issue description
I compiled my app (Paint.NET) for .NET 9-rc1. From my understanding this is the first build with the experimental dark mode functionality. Paint.NET has its own extensive Dark Mode theming with lots of custom painting, setting the right DWM attributes, and even sending a few not-really-documented-but-not-really-undocumented window messages to coerce certain controls to run in Dark Mode. For now I will not be using any of that, I am simply working on getting Paint.NET to boot up correctly in .NET 9 so that I can ship my own beta to the public and get more testing and validation.
This is how PDN should look when booting it up. This is running on .NET 8:
If I make one change, which is to target .NET 9 with this .NET 9-rc1 build, it looks like this:
Notice how the 4 floating window now have white title bars. This affects all child dialogs. The main window is not affected because I'm doing some very intensive (aka crazy) custom non-client painting in there.
I tracked this down to code in
Control.SetVisibleCore()
. It is calling aPrepareDarkMode
method which unconditionally callsDwmSetWindowAttribute
to set theDWMWA_USE_IMMERSIVE_DARK_MODE
attribute -- even if none of the experimental dark theme flags are enabled!winforms/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
Line 10572 in 062b0fe
I can almost work around this by overriding
SetVisibleCore
in the derived class, like so:However, this causes a different problem: when a Form is first shown, you can see the title bar start out as white and then animate towards the correct black color. This does not happen on .NET 8. This is clearly happening because the
DWMWA_USE_IMMERSIVE_DARK_MODE
attribute is being set twice:Desktop.2024.08.29.-.17.15.03.02.mp4
Paint.NET already manages this attribute, so I need WinForms to not manage it at all. I haven't enabled the experimental Dark Theme stuff, so I would expect literally no effect on any of my own custom theming, much of which will -- at least for now -- overlap with the experimental .NET dark theme stuff.
cc @KlausLoeffelmann
Steps to reproduce
I can provide access to a Paint.NET build and/or repository for reproducing this, if necessary.
The text was updated successfully, but these errors were encountered: