implement dpi aware with ui zoom on windows
This commit is contained in:
13
src/main.cpp
13
src/main.cpp
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user