Set process DPI aware on Windows/MSVC

This commit is contained in:
Edgaru089 2024-04-25 11:28:59 +08:00
parent fe10a149e5
commit 6fa2be3ce5

View File

@ -17,6 +17,17 @@ int main() {
#ifdef __MINGW32__ #ifdef __MINGW32__
SetProcessDPIAware(); SetProcessDPIAware();
#else
HINSTANCE user32Dll = LoadLibraryA("user32.dll");
if (user32Dll) {
typedef BOOL(WINAPI * SetProcessDPIAwareFuncType)();
SetProcessDPIAwareFuncType setProcessDPIAwareFunc = (SetProcessDPIAwareFuncType)GetProcAddress(user32Dll, "SetProcessDPIAware");
if (setProcessDPIAwareFunc) {
if (!setProcessDPIAwareFunc())
WARN("failed to set process DPI awareness");
}
FreeLibrary(user32Dll);
}
#endif #endif
HWND win = initgraph(SCREEN_WIDTH, SCREEN_HEIGHT); HWND win = initgraph(SCREEN_WIDTH, SCREEN_HEIGHT);
SetWindowTextA(win, "JacksEscape"); SetWindowTextA(win, "JacksEscape");