2017-09-22 00:50:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
2017-09-23 18:37:51 +02:00
|
|
|
#include <windows.h>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
|
|
#include <QLibrary>
|
2017-09-22 00:50:43 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace util {
|
|
|
|
static bool tryHandleDpiChangedMessage(void *message, int &dpi)
|
|
|
|
{
|
|
|
|
MSG *msg = reinterpret_cast<MSG *>(message);
|
|
|
|
|
|
|
|
// WM_DPICHANGED
|
|
|
|
if (msg->message == 0x02E0) {
|
|
|
|
dpi = HIWORD(msg->wParam);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-23 18:37:51 +02:00
|
|
|
|
|
|
|
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;
|
2017-09-22 00:50:43 +02:00
|
|
|
}
|
2017-09-23 18:37:51 +02:00
|
|
|
} // namespace util
|
|
|
|
} // namespace chatterino
|
2017-09-22 00:50:43 +02:00
|
|
|
|
|
|
|
#endif
|