@@ -462,6 +462,23 @@ const (
462462 TS_DRAW
463463)
464464
465+ type IMMERSIVE_HC_CACHE_MODE int
466+
467+ const (
468+ IHCM_USE_CACHED_VALUE IMMERSIVE_HC_CACHE_MODE = iota
469+ IHCM_REFRESH
470+ )
471+
472+ type PreferredAppMode int
473+
474+ const (
475+ Default PreferredAppMode = iota
476+ AllowDark
477+ ForceDark
478+ ForceLight
479+ Max
480+ )
481+
465482type DTTOPTS struct {
466483 DwSize uint32
467484 DwFlags uint32
@@ -619,3 +636,67 @@ func SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT {
619636
620637 return HRESULT (ret )
621638}
639+
640+ func ShouldAppsUseDarkMode () bool {
641+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 132 )
642+ if err != nil {
643+ return false
644+ }
645+ ret , _ , _ := syscall .Syscall (proc , 0 , 0 , 0 , 0 )
646+ return ret != 0
647+
648+ }
649+
650+ func IsDarkModeAllowedForWindow (hwnd HWND ) bool {
651+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 137 )
652+ if err != nil {
653+ return false
654+ }
655+ ret , _ , _ := syscall .Syscall (proc , 1 , uintptr (hwnd ), 0 , 0 )
656+ return ret != 0
657+
658+ }
659+
660+ func GetIsImmersiveColorUsingHighContrast (mode IMMERSIVE_HC_CACHE_MODE ) bool {
661+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 106 )
662+ if err != nil {
663+ return false
664+ }
665+ ret , _ , _ := syscall .Syscall (proc , 1 , uintptr (mode ), 0 , 0 )
666+ return ret != 0
667+
668+ }
669+
670+ func RefreshImmersiveColorPolicyState () {
671+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 104 )
672+ if err != nil {
673+ return
674+ }
675+ syscall .Syscall (proc , 0 , 0 , 0 , 0 )
676+ }
677+
678+ func AllowDarkModeForWindow (hwnd HWND , allow bool ) bool {
679+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 133 )
680+ if err != nil {
681+ return false
682+ }
683+ ret , _ , _ := syscall .Syscall (proc , 2 , uintptr (hwnd ), uintptr (BoolToBOOL (allow )), 0 )
684+ return ret != 0
685+ }
686+
687+ func SetPreferredAppMode (mode PreferredAppMode ) bool {
688+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 135 )
689+ if err != nil {
690+ return false
691+ }
692+ ret , _ , _ := syscall .Syscall (proc , 1 , uintptr (mode ), 0 , 0 )
693+ return ret != 0
694+ }
695+
696+ func FlushMenuThemes () {
697+ proc , err := windows .GetProcAddressByOrdinal (windows .Handle (libuxtheme .Handle ()), 136 )
698+ if err != nil {
699+ return
700+ }
701+ syscall .Syscall (proc , 0 , 0 , 0 , 0 )
702+ }
0 commit comments