implement dpi aware with ui zoom on windows

This commit is contained in:
2018-10-01 01:17:36 +02:00
parent daf3484426
commit d83fb68ec2
2 changed files with 14 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include "keymap.h"
#include "../resource.h"
#include <shellscalingapi.h>
#include <WbemCli.h>
#include "wacom.h"
#include <deque>
@@ -289,6 +290,8 @@ int main(int argc, char** argv)
WNDCLASS wc;
PIXELFORMATDESCRIPTOR pfd;
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
if (argc == 1)
App::I.initLog();
@@ -416,6 +419,16 @@ int main(int argc, char** argv)
}
}
auto monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
auto x = unsigned{};
auto y = unsigned{};
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
App::I.zoom = (float)x / 96.f;
// SetWindowPos(hWnd, NULL, 0, 0,
// (clientRect.right - clientRect.left) * App::I.zoom,
// (clientRect.bottom - clientRect.top) * App::I.zoom,
// SWP_NOREPOSITION | SWP_NOOWNERZORDER);
App::I.init();
ShowWindow(hWnd, SW_NORMAL);

View File

@@ -20,4 +20,5 @@
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "wbemuuid.lib")
#pragma comment(lib, "Shlwapi.lib")
#pragma comment(lib, "Shcore.lib")
#endif // _WIN32