Skip to content

Commit 38aa66c

Browse files
Merge pull request MediaArea#859 from cjee21/DPI-fix
Windows GUI: Use older API for getting system DPI
2 parents fb4fe15 + 4cb609f commit 38aa66c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Source/GUI/VCL/GUI_Main.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,16 @@ __fastcall TMainF::TMainF(TComponent* Owner)
243243
void __fastcall TMainF::GUI_Configure()
244244
{
245245
//Hard coded
246-
float DPIScale=static_cast<float>(GetSystemDpiForProcess(GetCurrentProcess()))/96;
246+
OSVERSIONINFO osvi;
247+
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
248+
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
249+
GetVersionEx(&osvi);
250+
int DPI;
251+
if (osvi.dwMajorVersion >= 10 && (osvi.dwMajorVersion > 10 || osvi.dwMinorVersion > 0 || osvi.dwBuildNumber >= 17134))
252+
DPI=GetSystemDpiForProcess(GetCurrentProcess());
253+
else
254+
DPI=GetDeviceCaps(GetDC(NULL), LOGPIXELSX);
255+
float DPIScale=static_cast<float>(DPI)/96;
247256
float ScaledScreenWidth=Screen->Width/DPIScale;
248257
float ScaledScreenHeight=Screen->Height/DPIScale;
249258
Width=500;

0 commit comments

Comments
 (0)