-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fd7fe2
commit 2ce4a8c
Showing
4 changed files
with
107 additions
and
14 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
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,3 @@ | ||
## 1.0 ([Dec 6, 2024](https://github.com/ramensoftware/windhawk-mods/blob/32a08d93bca7856d61c3bac57491c6a2ff7aaafa/mods/dark-menus.wh.cpp)) | ||
|
||
Initial release. |
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); | ||
} |
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