blob: 43856ccb271dedff8169538365df5dd31001ae64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
}
|