I found a way how to color the title bar of windows in Windows 11.
Code: Select all
EnableExplicit
; https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
; The documented enumeration values are not correct !!
; I played around with the values and found the following:
Enumeration DWMWINDOWATTRIBUTE
#DWMWA_USE_IMMERSIVE_DARK_MODE = 20
#DWMWA_BORDER_COLOR = 34
#DWMWA_CAPTION_COLOR = 35
#DWMWA_TEXT_COLOR = 36
EndEnumeration
; https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute
PrototypeC.i DwmSetWindowAttribute(hwnd.i, dwAttribute.l, *pvAttribute, cbAttribute.l)
Define.DwmSetWindowAttribute DwmSetWindowAttribute
Define.l CaptionColor, TextColor, BorderColor
Define.i UseDarkMode
OpenWindow(0, 50, 50, 600, 400, "Colored Window", #PB_Window_SystemMenu)
OpenWindow(1, 700, 50, 600, 400, "DarkMode Window", #PB_Window_SystemMenu)
CaptionColor = #Green
TextColor = #Blue
BorderColor = #Red
UseDarkMode = #True
If OpenLibrary(0, "dwmapi")
DwmSetWindowAttribute = GetFunction(0, "DwmSetWindowAttribute")
DwmSetWindowAttribute(WindowID(0), #DWMWA_CAPTION_COLOR, @CaptionColor, SizeOf(CaptionColor))
DwmSetWindowAttribute(WindowID(0), #DWMWA_TEXT_COLOR, @TextColor, SizeOf(TextColor))
DwmSetWindowAttribute(WindowID(0), #DWMWA_BORDER_COLOR, @BorderColor, SizeOf(BorderColor))
DwmSetWindowAttribute(WindowID(1), #DWMWA_USE_IMMERSIVE_DARK_MODE, @UseDarkMode, SizeOf(UseDarkMode))
CloseLibrary(0)
EndIf
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Unfortunately the DWMWINDOWATTRIBUTE enumeration is not documented correctly by Microsoft.
https://docs.microsoft.com/en-us/window ... wattribute
I found out the correct values by trial and error.
Also, this code only works on Windows 11.
Does anyone have an idea if and how this could be done on Windows 10?