1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Prevent initial DPI scaling of dialog windows

Fixes oversized dialogs (except non-client area) in some fullscreen games,
e.g. Close Combat 4.

Fixes mispositioned trackbar sliders in Red Alert 2.
This commit is contained in:
narzoul 2024-06-28 00:11:49 +02:00
parent 7237acb11c
commit eeb0682ced

View File

@ -53,6 +53,7 @@ namespace
};
decltype(&DwmSetIconicThumbnail) g_dwmSetIconicThumbnail = nullptr;
decltype(&GetDpiForSystem) g_getDpiForSystem = nullptr;
std::map<HMENU, UINT> g_menuMaxHeight;
@ -391,6 +392,16 @@ namespace
return result;
}
UINT WINAPI getDpiForSystem()
{
LOG_FUNC("GetDpiForSystem");
if (0 != g_inCreateDialog || 0 != g_inMessageBox)
{
return LOG_RESULT(96);
}
return LOG_RESULT(g_getDpiForSystem());
}
BOOL WINAPI getMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
decltype(&GetMessageA) origGetMessage)
{
@ -954,6 +965,13 @@ namespace Gdi
g_dwmSetIconicThumbnail = reinterpret_cast<decltype(&DwmSetIconicThumbnail)>(
GetProcAddress(GetModuleHandle("dwmapi"), "DwmSetIconicThumbnail"));
g_getDpiForSystem = reinterpret_cast<decltype(&GetDpiForSystem)>(
GetProcAddress(GetModuleHandle("user32"), "GetDpiForSystem"));
if (g_getDpiForSystem)
{
Compat::hookFunction(reinterpret_cast<void*&>(g_getDpiForSystem), getDpiForSystem, "GetDpiForSystem");
}
Compat::hookIatFunction(Dll::g_origDDrawModule, "SetWindowLongA", ddrawSetWindowLongA);
SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE,