fixed windows 7 again

This commit is contained in:
fourtf 2018-06-25 12:41:55 +02:00
parent 7b5972f05d
commit c75b3578a7

View file

@ -26,9 +26,17 @@
#include <gdiplus.h>
#include <windowsx.h>
#include <ShellScalingApi.h>
//#include <ShellScalingApi.h>
#pragma comment(lib, "Dwmapi.lib")
#pragma comment(lib, "Shcore.lib")
typedef enum MONITOR_DPI_TYPE {
MDT_EFFECTIVE_DPI = 0,
MDT_ANGULAR_DPI = 1,
MDT_RAW_DPI = 2,
MDT_DEFAULT = MDT_EFFECTIVE_DPI
} MONITOR_DPI_TYPE;
typedef HRESULT(CALLBACK *GetDpiForMonitor_)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *);
#include <QHBoxLayout>
#include <QVBoxLayout>
@ -441,17 +449,23 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
// if (IsWindows8Point1OrGreater()) {
HINSTANCE shcore = LoadLibrary(L"Shcore.dll");
if (shcore != nullptr && GetProcAddress(shcore, "GetDpiForMonitor") != nullptr) {
if (shcore != nullptr) {
if (auto getDpiForMonitor =
(GetDpiForMonitor_)GetProcAddress(shcore, "GetDpiForMonitor")) {
HMONITOR monitor = MonitorFromWindow(msg->hwnd, MONITOR_DEFAULTTONEAREST);
UINT xScale, yScale;
GetDpiForMonitor(monitor, MDT_DEFAULT, &xScale, &yScale);
getDpiForMonitor(monitor, MDT_DEFAULT, &xScale, &yScale);
// GetDpiForMonitor(monitor, MDT_DEFAULT, &xScale, &yScale);
float scale = xScale / 96.f;
this->nativeScale_ = scale;
this->updateScale();
}
}
return true;
}
case WM_NCCALCSIZE: {