diff options
author | Sven Gothel <sgothel@jausoft.com> | 2023-01-31 03:57:48 +0100 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2023-01-31 03:57:48 +0100 |
commit | bebb7e9b078f6eaed478143ffbdeeece5ca0e037 (patch) | |
tree | 19eb9d743a7aa0ebc1128f314cd3fb535a344c9d /src/nativewindow/native/win32/WindowsUser.c | |
parent | e96aeb6e9acd2b1435f5fad244a1488e74a3a6d6 (diff) |
GDIUtil: Add GetMonitor*() variants incl. PixelScale (Part-2, adding missing native header and code files)
Part-1 in commit e96aeb6e9acd2b1435f5fad244a1488e74a3a6d6
Diffstat (limited to 'src/nativewindow/native/win32/WindowsUser.c')
-rw-r--r-- | src/nativewindow/native/win32/WindowsUser.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nativewindow/native/win32/WindowsUser.c b/src/nativewindow/native/win32/WindowsUser.c new file mode 100644 index 000000000..43856ccb2 --- /dev/null +++ b/src/nativewindow/native/win32/WindowsUser.c @@ -0,0 +1,33 @@ + +#include <windows.h> +#include "WindowsUser.h" + +#include <stdlib.h> +#include <stdio.h> + +// #define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(args...) fprintf(stderr, args); +#else + #define DBG_PRINT(args...) +#endif + +// MONITOR_DEFAULTTONULL 0x00000000 +// MONITOR_DEFAULTTOPRIMARY 0x00000001 +// MONITOR_DEFAULTTONEAREST 0x00000002 + +HMONITOR GetMonitorFromWindow(HWND hwnd) { + return MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); +} + +HMONITOR GetMonitorFromPoint(int x, int y) { + POINT pt = { (LONG)x, (LONG)y }; + return MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); +} + +HMONITOR GetMonitorFromRect(int left, int top, int right, int bottom) { + RECT rect = { (LONG)left, (LONG)top, (LONG)right, (LONG)bottom }; + return MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); +} + |