Skip to content

Commit

Permalink
uxtheme: add undocumented darkmode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zx2c4 committed Oct 25, 2019
1 parent cc00c74 commit d5a3d07
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions uxtheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,47 @@ func SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT {

return HRESULT(ret)
}

func RefreshImmersiveColorPolicyState() {
proc, err := windows.GetProcAddressByOrdinal(windows.Handle(libuxtheme.Handle()), 104)
if err != nil {
return
}
syscall.Syscall(proc, 0, 0, 0, 0)
}

func ShouldAppsUseDarkMode() bool {
proc, err := windows.GetProcAddressByOrdinal(windows.Handle(libuxtheme.Handle()), 132)
if err != nil {
return false
}
ret, _, _ := syscall.Syscall(proc, 0, 0, 0, 0)
return ret != 0

}

func AllowDarkModeForWindow(hwnd HWND, allow bool) bool {
proc, err := windows.GetProcAddressByOrdinal(windows.Handle(libuxtheme.Handle()), 133)
if err != nil {
return false
}
ret, _, _ := syscall.Syscall(proc, 2, uintptr(hwnd), uintptr(BoolToBOOL(allow)), 0)
return ret != 0
}

func AllowDarkModeForApp(allow bool) bool {
proc, err := windows.GetProcAddressByOrdinal(windows.Handle(libuxtheme.Handle()), 135)
if err != nil {
return false
}
ret, _, _ := syscall.Syscall(proc, 1, uintptr(BoolToBOOL(allow)), 0, 0)
return ret != 0
}

func FlushMenuThemes() {
proc, err := windows.GetProcAddressByOrdinal(windows.Handle(libuxtheme.Handle()), 136)
if err != nil {
return
}
syscall.Syscall(proc, 0, 0, 0, 0)
}

0 comments on commit d5a3d07

Please sign in to comment.