Skip to content

Commit

Permalink
Make the WoW client use a dark title bar if the user is running dark …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
NightQuest committed Sep 5, 2024
1 parent cff4f5b commit d5a8afe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ add_library(WoWHook MODULE ${source_files})
# Make sure the output filename is dinput8.dll
set_target_properties(WoWHook PROPERTIES OUTPUT_NAME "dinput8")

target_link_libraries(WoWHook PRIVATE dwmapi.lib)

target_precompile_headers(WoWHook PUBLIC src/preCompiled.h)

install(TARGETS WoWHook LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})
26 changes: 18 additions & 8 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,30 @@ void Application::OnDetach()

void Application::OnFrame(IDirect3DDevice9* device)
{
#ifdef _DEBUG
static unsigned int frame = 0;
if( frame < 2 && ++frame == 2 )
MessageBox(NULL, "We're hooked in", "Success!", MB_OK);

static bool fullyLoaded = false;
if( fullyLoaded == false )
{
if( (fullyLoaded = eng->IsPlayerInGame()) == true )
if( auto* device = eng->GetDeviceD3d() )
{
MessageBox(NULL, "Player has entered the world!", "Loaded", MB_OK);
HWND hwnd = device->GetWindowHandle();
if( hwnd )
{
HKEY hKey;
if( ::RegOpenKey(HKEY_CURRENT_USER, R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize)", &hKey) == ERROR_SUCCESS )
{
DWORD dwType = REG_DWORD, dwSize = sizeof(DWORD);
DWORD dwAttrib = FALSE;

if( ::RegQueryValueEx(hKey, "AppsUseLightTheme", nullptr, &dwType, reinterpret_cast<LPBYTE>(&dwAttrib), &dwSize) == ERROR_SUCCESS )
{
BOOL darkMode = !dwAttrib;
::DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkMode, sizeof(BOOL));
}
::RegCloseKey(hKey);
}
}
}
}
#endif
}

UINT32 Application::GetSafeDisplayId()
Expand Down
1 change: 1 addition & 0 deletions src/preCompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <dwmapi.h>
#include <d3d9.h>

// std headers
Expand Down

0 comments on commit d5a8afe

Please sign in to comment.