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, the scroll bar theme is incorrect. #10665

Closed
EVA-SS opened this issue Jan 16, 2024 · 11 comments
Closed

Dark mode, the scroll bar theme is incorrect. #10665

EVA-SS opened this issue Jan 16, 2024 · 11 comments

Comments

@EVA-SS
Copy link

EVA-SS commented Jan 16, 2024

.NET version

.net6.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

all

Issue description

After enabling dark mode, the scroll bar remains in the light theme.

DarkTestGIF

        private void button1_Click(object sender, EventArgs e)
        {
            Dark = !Dark;
        }

        bool dark = false;
        public bool Dark
        {
            get => dark;
            set
            {
                dark = value;
                if (value)
                {
                    BackColor = Color.Black;
                    ForeColor = Color.White;
                }
                else
                {
                    BackColor = Color.White;
                    ForeColor = Color.Black;
                }
                int useImmersiveDarkMode = value ? 1 : 0;
                DwmSetWindowAttribute(Handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref useImmersiveDarkMode, sizeof(int));
            }
        }

        #region DarkDwm

        [DllImport("dwmapi.dll")]
        static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);

        const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;

        #endregion

DarkTest.zip

Steps to reproduce

After invoking "Dark=true", the scroll bar color remains in the light theme.

@EVA-SS EVA-SS added the untriaged The team needs to look at this issue in the next triage label Jan 16, 2024
@elachlan
Copy link
Contributor

elachlan commented Jan 16, 2024

Call Invalidate() after the call to DwmSetWindowAttribute.
https://stackoverflow.com/a/62811758

EDIT: unsure if that will actually help.

@merriemcgaw
Copy link
Member

We are unable to change the background color of scrollbars. This is an area that we're looking at for the theming and seeing if we can get a solution in the future. For now, this is a known issue.

@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Jan 16, 2024
@merriemcgaw merriemcgaw added this to the Future milestone Jan 16, 2024
@EVA-SS
Copy link
Author

EVA-SS commented Jan 17, 2024

😭Alright, this is pretty frustrating, I'm really hoping to get some good news from you guys.

@elachlan
Copy link
Contributor

@EVA-SS I'd encourage you to investigate a solution if you have the time and ability. Especially if this is blocking you and your app.

@elachlan
Copy link
Contributor

elachlan commented Jan 17, 2024

This looks promising!

The WM_CTLCOLORSCROLLBAR message is used only by child scroll bar controls. Scrollbars attached to a window (WS_SCROLL and WS_VSCROLL) do not generate this message. To customize the appearance of scrollbars attached to a window, use the flat scroll bar functions.

And disappointment:

Flat scroll bars are supported by Comctl32.dll versions 4.71 through 5.82. Comctl32.dll versions 6.00 and later do not support flat scroll bars.

@EVA-SS
Copy link
Author

EVA-SS commented Jan 17, 2024

This looks promising!

The WM_CTLCOLORSCROLLBAR message is used only by child scroll bar controls. Scrollbars attached to a window (WS_SCROLL and WS_VSCROLL) do not generate this message. To customize the appearance of scrollbars attached to a window, use the flat scroll bar functions.

And disappointment:

Flat scroll bars are supported by Comctl32.dll versions 4.71 through 5.82. Comctl32.dll versions 6.00 and later do not support flat scroll bars.

🙂 Thank you for bringing up the idea, FlatSB can indeed change the scrollbar style. As you pointed out, there are some issues with it, and it's not perfect. overriding the native scrollbar is a challenging task indeed.

@elachlan
Copy link
Contributor

Maybe its something that can be done using VisualStyles and the ScrollBarRenderer?

@EVA-SS
Copy link
Author

EVA-SS commented Jan 17, 2024

#4479 #2040 I think currently, ScrollBarRenderer isn't up to the task.

@elachlan
Copy link
Contributor

@EVA-SS Are you happy for me to close this issue in favor of those issues?

@EVA-SS
Copy link
Author

EVA-SS commented Jan 17, 2024

okay

@EVA-SS EVA-SS closed this as completed Jan 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2024
@KlausLoeffelmann
Copy link
Member

#10985

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants