Krypton-Suite-Legacy-Archive/Krypton-NET-5.470

[New Feature Request]: Win10 dark mode scrollbars

Opened this issue · 2 comments

Credit to @Lathea for this info:

[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern int SetWindowTheme(IntPtr hwnd, string pszSubAppName, string pszSubIdList);

then override the HandleCreated() and put this in it:
SetWindowTheme(Handle, "DarkMode_Explorer", null);

dark mode scroll bars! I've been stressing about this for a long time as the default scroll bars stick out a mile on any theme other than light. This has to be done on a control by control basis (ie KryptonTreeView, KryptonListBox)

It seems this may change as I am not sure how official it is. It works, even when win10 is in Light mode.

need to wrap the SetWindowTheme() call in an if that detects the current Krypton theme and then applies it or not depending on what looks best. It still looks odd for coloured themes, but at least a dark theme should be ok

Stick the call into VisualControlBase and anything that is using that (Most of the toolkit apart from some ribbons I recall) will get the switch as required.

Use something like OnGlobalPaletteChanged(...) to catch the pallete change and then set a flag.
Use the flag and a call from within the constructor to set the call for the darkTheme mode for the scroll bars of that control.

OR,
read up on the use of WM_CTLCOLORSCROLLBAR
and on the use of WS_EX_LEFTSCROLLBAR or WS_VSCOLL to check if a VisualControlBase needs to have the scroll override applied. (via the use of WindowStylesHelper.HScrollBar)