dark theme scrollbars #411

Closed
opened 2026-01-30 21:51:14 +00:00 by claunia · 13 comments
Owner

Originally created by @musm on GitHub (Oct 10, 2018).

Originally assigned to: @miniksa on GitHub.

can we add the option that if you are using the dark theme in windows that the scrollbars in the prompt
image

match the dark scrollbars in e.g. explorer

image

Originally created by @musm on GitHub (Oct 10, 2018). Originally assigned to: @miniksa on GitHub. can we add the option that if you are using the dark theme in windows that the scrollbars in the prompt ![image](https://user-images.githubusercontent.com/4319522/46749913-c523b080-cc84-11e8-923e-e891358096ed.png) match the dark scrollbars in e.g. explorer ![image](https://user-images.githubusercontent.com/4319522/46749950-e389ac00-cc84-11e8-9886-172fd3198a45.png)
claunia added the Issue-FeatureProduct-ConhostResolution-Fix-AvailableWork-Item labels 2026-01-30 21:51:14 +00:00
Author
Owner

@ysc3839 commented on GitHub (Oct 11, 2018):

Try:

SetWindowTheme(GetConsoleWindow(), L"DarkMode_Explorer", nullptr);

In your console application.

Correct way is using internal API AllowDarkModeForWindow.
I think console team have known such feature, they just too busy to support it. So just wait.

@ysc3839 commented on GitHub (Oct 11, 2018): Try: ``` SetWindowTheme(GetConsoleWindow(), L"DarkMode_Explorer", nullptr); ``` In your console application. Correct way is using internal API `AllowDarkModeForWindow`. I think console team have known such feature, they just too busy to support it. So just wait.
Author
Owner

@miniksa commented on GitHub (Oct 11, 2018):

Made a change today to try this out for Insiders builds.

@miniksa commented on GitHub (Oct 11, 2018): Made a change today to try this out for Insiders builds.
Author
Owner

@musm commented on GitHub (Oct 11, 2018):

@miniksa awesome, which build number? I'm on the slow ring fyi.

@musm commented on GitHub (Oct 11, 2018): @miniksa awesome, which build number? I'm on the slow ring fyi.
Author
Owner

@zadjii-msft commented on GitHub (Oct 11, 2018):

@musm It'll be out in a few weeks. It usually takes just about 3 weeks for checkins we make to get up to master, and usually a week after that for the Insider's build to get spun with the change.

So, soontm

@zadjii-msft commented on GitHub (Oct 11, 2018): @musm It'll be out in a few weeks. It usually takes just about 3 weeks for checkins we make to get up to master, and usually a week after that for the Insider's build to get spun with the change. So, soon<sup>tm</sup>
Author
Owner

@oising commented on GitHub (Oct 11, 2018):

Hmm, I tried what @ysc3839 said in powershell (on 1809, of course) and it had no effect on the scrollbars:

PS> add-type -Name NativeMethods -Namespace Temp -MemberDefinition @"
[DllImport("uxtheme.dll", SetLastError=true, ExactSpelling=true, CharSet=CharSet.Unicode)]
public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr GetConsoleWindow();
"@
PS> [Temp.NativeMethods]::SetWindowTheme([Temp.NativeMethods]::GetConsoleWindow(),
               "DarkMode_Explorer", $null)
0
PS> # scrollbars still light theme

Suggestions on how to correct this, @zadjii-msft or @miniksa ?

@oising commented on GitHub (Oct 11, 2018): Hmm, I tried what @ysc3839 said in powershell (on 1809, of course) and it had no effect on the scrollbars: ```powershell PS> add-type -Name NativeMethods -Namespace Temp -MemberDefinition @" [DllImport("uxtheme.dll", SetLastError=true, ExactSpelling=true, CharSet=CharSet.Unicode)] public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); [DllImport("kernel32.dll", SetLastError=true)] public static extern IntPtr GetConsoleWindow(); "@ PS> [Temp.NativeMethods]::SetWindowTheme([Temp.NativeMethods]::GetConsoleWindow(), "DarkMode_Explorer", $null) 0 PS> # scrollbars still light theme ``` Suggestions on how to correct this, @zadjii-msft or @miniksa ?
Author
Owner

@miniksa commented on GitHub (Oct 11, 2018):

I'm really not sure why it doesn't work from the outside. Could be that it doesn't like being done after ShowWindow has been called and the WM_SETTINGCHANGED handler isn't ready for it. Could be that SetWindowTheme generates a window message that UIPI is blocking from your Powershell binary. Could be something completely different. I'm sorry. I tried it inside the console code and it works, so I'm not intending to spend anytime debugging why it doesn't work from the outside.

@miniksa commented on GitHub (Oct 11, 2018): I'm really not sure why it doesn't work from the outside. Could be that it doesn't like being done after `ShowWindow` has been called and the `WM_SETTINGCHANGED` handler isn't ready for it. Could be that `SetWindowTheme` generates a window message that UIPI is blocking from your Powershell binary. Could be something completely different. I'm sorry. I tried it inside the console code and it works, so I'm not intending to spend anytime debugging why it doesn't work from the outside.
Author
Owner

@musm commented on GitHub (Oct 11, 2018):

(unrelated) @ysc3839 can you provide me with some simple minimal example with that in use? Trying to dive in so I can create PRs for some apps I use, but the win32 API world is a little dizzying for first timers.

@musm commented on GitHub (Oct 11, 2018): (unrelated) @ysc3839 can you provide me with some simple minimal example with that in use? Trying to dive in so I can create PRs for some apps I use, but the win32 API world is a little dizzying for first timers.
Author
Owner

@ysc3839 commented on GitHub (Oct 12, 2018):

@musm
It works on my GUI application. Currently I have not tested on console Windows.
Maybe SetWindowTheme for external process is not allowed.

https://github.com/ysc3839/VCMPBrowser/blob/darkmode/DarkMode.h
This code uses internal APIs and may not work on a newer Windows version.

PS: Hope Microsoft makes these APIs public for all Win32 apps.

@ysc3839 commented on GitHub (Oct 12, 2018): @musm It works on my GUI application. Currently I have not tested on console Windows. Maybe SetWindowTheme for external process is not allowed. https://github.com/ysc3839/VCMPBrowser/blob/darkmode/DarkMode.h This code uses internal APIs and may not work on a newer Windows version. PS: Hope Microsoft makes these APIs public for all Win32 apps.
Author
Owner

@be5invis commented on GitHub (Nov 3, 2018):

Does the dark mode cover settings dialog?

@be5invis commented on GitHub (Nov 3, 2018): Does the dark mode cover settings dialog?
Author
Owner

@miniksa commented on GitHub (Jan 18, 2019):

MSFT: 19271078 reached Insiders for 18272+.

The follow on fix for a mistake (MSFT: 19548142) reached Insiders for 18309+.

@miniksa commented on GitHub (Jan 18, 2019): MSFT: 19271078 reached Insiders for 18272+. The follow on fix for a mistake (MSFT: 19548142) reached Insiders for 18309+.
Author
Owner

@ysc3839 commented on GitHub (Feb 16, 2019):

@miniksa I reverse engineered and found you use GetProcAddress with a magic number. Why not static link to that function?
I'm afraid that the console will broken when the ordinal of that function changed.

image

@ysc3839 commented on GitHub (Feb 16, 2019): @miniksa I reverse engineered and found you use GetProcAddress with a magic number. Why not static link to that function? I'm afraid that the console will broken when the ordinal of that function changed. ![image](https://user-images.githubusercontent.com/12028138/52904788-c5077300-326b-11e9-9fd9-aa9211683a83.png)
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 16, 2019):

@ysc3839 There's a couple reasons for that:

  1. The function may not be exported by name.
  2. We can't statically link it, as the library that provides it is a dynamic library.
  3. We all use the console internally every day, and are very likely to be the first to know if this ordinal changes, probably through a change in its observable behavior. Since we're developing on builds of windows that are very close to mainline, we'll almost certainly figure out changes like this before any breakage makes it out to Insiders.
    1. (additionally, any given ordinal is not at risk of changing during the lifetime of a single version of Windows)
@DHowett-MSFT commented on GitHub (Feb 16, 2019): @ysc3839 There's a couple reasons for that: 1. The function may not be exported by name. 2. We can't statically link it, as the library that provides it is a dynamic library. 3. We all use the console internally every day, and are very likely to be the first to know if this ordinal changes, probably through a change in its observable behavior. Since we're developing on builds of windows that are _very close_ to mainline, we'll almost certainly figure out changes like this before any breakage makes it out to Insiders. 1. (additionally, any given ordinal is not at risk of changing during the lifetime of a single version of Windows)
Author
Owner

@ysc3839 commented on GitHub (Feb 16, 2019):

@DHowett-MSFT
Sorry, the "static link" means link to that DLL using import address table.
Some other DLL (explorerframe.dll) link to that function using IAT. It's better than using GetProcAddress.

@ysc3839 commented on GitHub (Feb 16, 2019): @DHowett-MSFT Sorry, the "static link" means link to that DLL using import address table. Some other DLL (explorerframe.dll) link to that function using IAT. It's better than using GetProcAddress.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#411