fixed dpi not initializing when the window shows

This commit is contained in:
Daniel _
2017-09-23 18:37:51 +02:00
parent 14511e10ef
commit 206a3518b0
6 changed files with 46 additions and 9 deletions
+21 -2
View File
@@ -1,7 +1,10 @@
#pragma once
#ifdef USEWINSDK
#include "windows.h"
#include <windows.h>
#include <boost/optional.hpp>
#include <QLibrary>
namespace chatterino {
namespace util {
@@ -17,7 +20,23 @@ static bool tryHandleDpiChangedMessage(void *message, int &dpi)
}
return false;
}
static boost::optional<UINT> getWindowDpi(quintptr ptr)
{
typedef UINT(WINAPI * GetDpiForWindow)(HWND);
QLibrary user32("user32.dll", NULL);
GetDpiForWindow getDpiForWindow = (GetDpiForWindow)user32.resolve("GetDpiForWindow");
if (getDpiForWindow) {
UINT value = getDpiForWindow((HWND)ptr);
return value == 0 ? boost::none : boost::optional<UINT>(value);
}
return boost::none;
}
}
} // namespace util
} // namespace chatterino
#endif