Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-03-15 17:41:16 +08:00
parent 942fd02b66
commit 6bbbc0a145
1 changed files with 6 additions and 2 deletions

View File

@ -39,8 +39,10 @@
#endif #endif
#include "qwinregistry_p.h" #include "qwinregistry_p.h"
#include "framelesshelper_windows.h" #include "framelesshelper_windows.h"
#if 0
#include <atlbase.h> #include <atlbase.h>
#include <d2d1_1.h> #include <d2d1.h>
#endif
Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(QMargins)
@ -607,11 +609,12 @@ quint32 Utilities::getPrimaryScreenDpi(const bool horizontal)
} }
} }
} }
#if 0 // Crash on Windows 7, to be investigated.
static const auto pD2D1CreateFactory = static const auto pD2D1CreateFactory =
reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, void **)>( reinterpret_cast<HRESULT(WINAPI *)(D2D1_FACTORY_TYPE, REFIID, void **)>(
QSystemLibrary::resolve(QStringLiteral("d2d1"), "D2D1CreateFactory")); QSystemLibrary::resolve(QStringLiteral("d2d1"), "D2D1CreateFactory"));
if (pD2D1CreateFactory) { if (pD2D1CreateFactory) {
CComPtr<ID2D1Factory1> d2dFactory = nullptr; CComPtr<ID2D1Factory> d2dFactory = nullptr;
if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_PPV_ARGS(&d2dFactory)))) { if (SUCCEEDED(pD2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_PPV_ARGS(&d2dFactory)))) {
if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) { if (SUCCEEDED(d2dFactory->ReloadSystemMetrics())) {
FLOAT dpiX = 0.0, dpiY = 0.0; FLOAT dpiX = 0.0, dpiY = 0.0;
@ -623,6 +626,7 @@ QT_WARNING_POP
} }
} }
} }
#endif
const HDC hdc = GetDC(nullptr); const HDC hdc = GetDC(nullptr);
if (hdc) { if (hdc) {
const int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); const int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);