Terminal: dark theme scrollbars

Created on 10 Oct 2018  路  13Comments  路  Source: microsoft/terminal

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

Issue-Feature Product-Conhost Resolution-Fix-Available Work-Item

Most helpful comment

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

All 13 comments

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.

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

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

@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

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 ?

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.

(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
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.

Does the dark mode cover settings dialog?

MSFT: 19271078 reached Insiders for 18272+.

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

@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 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
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.

Was this page helpful?
0 / 5 - 0 ratings