|
10 | 10 | *****************************************************************************/ |
11 | 11 |
|
12 | 12 | #include "StdInc.h" |
| 13 | +#include <dwmapi.h> |
| 14 | +#include <resource.h> |
| 15 | + |
| 16 | +extern HINSTANCE g_hModule; |
| 17 | + |
13 | 18 | HRESULT HandleCreateDeviceResult(HRESULT hResult, IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, |
14 | 19 | D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); |
15 | 20 | std::vector<IDirect3D9*> ms_CreatedDirect3D9List; |
@@ -166,6 +171,27 @@ HRESULT CProxyDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND |
166 | 171 | SetWindowTextW(hFocusWindow, MbUTF8ToUTF16("MTA: San Andreas").c_str()); |
167 | 172 | #endif |
168 | 173 |
|
| 174 | + // Set dark titlebar if needed |
| 175 | + BOOL darkTitleBar = GetSystemRegistryValue((uint)HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme") == "\x0"; |
| 176 | + DwmSetWindowAttribute(hFocusWindow, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkTitleBar, sizeof(darkTitleBar)); |
| 177 | + |
| 178 | + // Update icon |
| 179 | + if (HICON icon = LoadIcon(g_hModule, MAKEINTRESOURCE(IDI_ICON1))) |
| 180 | + { |
| 181 | + const auto paramIcon = reinterpret_cast<LPARAM>(icon); |
| 182 | + for (const WPARAM size : {ICON_SMALL, ICON_BIG}) |
| 183 | + { |
| 184 | + SendMessage(hFocusWindow, WM_SETICON, size, paramIcon); |
| 185 | + } |
| 186 | + |
| 187 | + // Clean |
| 188 | + DestroyIcon(icon); |
| 189 | + } |
| 190 | + |
| 191 | + // Redraw, we avoid possible problems with the fact that it won't replace the icon somewhere |
| 192 | + InvalidateRect(hFocusWindow, nullptr, TRUE); |
| 193 | + UpdateWindow(hFocusWindow); |
| 194 | + |
169 | 195 | // Detect if second call to CreateDevice |
170 | 196 | if (CreateDeviceSecondCallCheck(hResult, m_pDevice, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface)) |
171 | 197 | { |
|
0 commit comments