-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathScreenMetric.cpp
53 lines (43 loc) · 1.07 KB
/
ScreenMetric.cpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <windows.h>
#include "ScreenMetric.h"
ScreenMetric::ScreenMetric()
{
this->_xSystemSize = GetSystemMetrics(SM_CXSCREEN);
this->_ySystemSize = GetSystemMetrics(SM_CYSCREEN);
HDC hDC = GetDC(NULL);
this->_xDeviceSize = GetDeviceCaps(hDC, DESKTOPHORZRES);
this->_yDeviceSize = GetDeviceCaps(hDC, DESKTOPVERTRES);
ReleaseDC(NULL, hDC);
}
int ScreenMetric::xSystemSize() const
{
return this->_xSystemSize;
}
int ScreenMetric::ySystemSize() const
{
return this->_ySystemSize;
}
int ScreenMetric::xDeviceSize() const
{
return this->_xDeviceSize;
}
int ScreenMetric::yDeviceSize() const
{
return this->_yDeviceSize;
}
int ScreenMetric::xSystemToDevice(int x) const
{
return x * this->_xDeviceSize / this->_xSystemSize;
}
int ScreenMetric::ySystemToDevice(int y) const
{
return y * this->_yDeviceSize / this->_ySystemSize;
}
int ScreenMetric::xDeviceToSystem(int x) const
{
return x * this->_xSystemSize / this->_xDeviceSize;
}
int ScreenMetric::yDeviceToSystem(int y) const
{
return y * this->_ySystemSize / this->_yDeviceSize;
}