-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dark-menus * Update dark-menus.wh.cpp * Second Update
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// ==WindhawkMod== | ||
// @id dark-menus | ||
// @name Dark mode context menus | ||
// @description Enables dark mode for all win32 menus. | ||
// @version 1.0 | ||
// @author Mgg Sk | ||
// @github https://github.com/MGGSK | ||
// @include * | ||
// ==/WindhawkMod== | ||
|
||
// ==WindhawkModReadme== | ||
/* | ||
# Dark mode context menus | ||
Forces dark mode for all win32 context menus to create a more consistent UI. | ||
### Before: | ||
![Before](https://i.imgur.com/bGRVJz8.png) | ||
### After: | ||
![After](https://i.imgur.com/BURKEki.png) | ||
*/ | ||
// ==/WindhawkModReadme== | ||
|
||
#include <minwindef.h> | ||
#include <winerror.h> | ||
|
||
enum AppMode | ||
{ | ||
Default, | ||
AllowDark, | ||
ForceDark, | ||
ForceLight, | ||
Max | ||
}; | ||
|
||
using FlushMenuThemes_T = void (WINAPI *)(); | ||
using SetPreferredAppMode_T = HRESULT (WINAPI *)(AppMode appMode); | ||
|
||
FlushMenuThemes_T FlushMenuThemes; | ||
SetPreferredAppMode_T SetPreferredAppMode; | ||
|
||
//Applies the theme to all menus. | ||
HRESULT ApplyTheme() | ||
{ | ||
FlushMenuThemes(); | ||
return SetPreferredAppMode(ForceDark); | ||
} | ||
|
||
//Import functions | ||
BOOL Wh_ModInit() { | ||
HMODULE hUxtheme = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); | ||
FARPROC pSetPreferredAppMode = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135)); | ||
FARPROC pFlushMenuThemes = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)); | ||
|
||
SetPreferredAppMode = reinterpret_cast<SetPreferredAppMode_T>(pSetPreferredAppMode); | ||
FlushMenuThemes = reinterpret_cast<FlushMenuThemes_T>(pFlushMenuThemes); | ||
|
||
HRESULT hResult = ApplyTheme(); | ||
return SUCCEEDED(hResult); | ||
} | ||
|
||
//Restores the default theme. | ||
void Wh_ModUninit() | ||
{ | ||
FlushMenuThemes(); | ||
SetPreferredAppMode(Default); | ||
} |