Josh Posted December 17, 2022 Share Posted December 17, 2022 You can make a Window have dark / black titlebar without overriding drawing: #include <dwmapi.h> // put this somewhere... //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR); BOOL USE_DARK_MODE = true; BOOL SET_IMMERSIVE_DARK_MODE_SUCCESS = SUCCEEDED(DwmSetWindowAttribute( window->GetHandle(), DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE, &USE_DARK_MODE, sizeof(USE_DARK_MODE))); window->SetHidden(false); This requires the WIndows 11 SDK to be installed (which still works with Win10). Unfortunately on Windows 10 it appears all this does is prevent the window titlebar from being white when it is not active. The titlbar will still be the primary system color when the window is active. But it's an improvement. https://stackoverflow.com/questions/39261826/change-the-color-of-the-title-bar-caption-of-a-win32-application 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted February 25, 2023 Share Posted February 25, 2023 I've been playing with this. I found out that you can combine this snip with the one below along with Interface::LoadColorScheme, you can get your app to be painted in the user's theme on Windows. Something that would be nice is to have an event we can use, but I don't think the OS makes one when the theme is changed. bool is_light_theme() { // based on https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application // The value is expected to be a REG_DWORD, which is a signed 32-bit little-endian auto buffer = std::vector<char>(4); auto cbData = static_cast<DWORD>(buffer.size() * sizeof(char)); auto res = RegGetValueW( HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", RRF_RT_REG_DWORD, // expected value type nullptr, buffer.data(), &cbData); if (res != ERROR_SUCCESS) { throw std::runtime_error("Error: error_code=" + std::to_string(res)); } // convert bytes written to our buffer to an int, assuming little-endian auto i = int(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]); return i == 1; } 2 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.