-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.h
76 lines (56 loc) · 1.62 KB
/
utils.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "gui.h"
#include <physicalmonitorenumerationapi.h>
#include <highlevelmonitorconfigurationapi.h>
#pragma comment(lib, "Dxva2.lib")
HANDLE GetMonitor() {
DWORD NumberOfPhysicalMonitors{ 0 };
PHYSICAL_MONITOR* PhysicalMonitors{ nullptr };
HMONITOR hMonitor{ MonitorFromWindow(GetTopWindow(nullptr), NULL) };
if (!hMonitor || hMonitor == INVALID_HANDLE_VALUE) {
return INVALID_HANDLE_VALUE;
}
if (!GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &NumberOfPhysicalMonitors)) {
return INVALID_HANDLE_VALUE;
}
PhysicalMonitors = static_cast<PHYSICAL_MONITOR*>(malloc(
NumberOfPhysicalMonitors * sizeof(PHYSICAL_MONITOR)
));
if (!GetPhysicalMonitorsFromHMONITOR(hMonitor,
NumberOfPhysicalMonitors,
PhysicalMonitors)) {
free(PhysicalMonitors);
return INVALID_HANDLE_VALUE;
}
return PhysicalMonitors->hPhysicalMonitor;
}
COLORREF StringToColor(std::string SourceString) {
for (int i = 0; i < SourceString.length(); i++) {
SourceString[i] = std::tolower(SourceString[i]);
}
if (SourceString == "white") {
return RGB(255, 255, 255);
}
if (SourceString == "black") {
return RGB(0, 0, 0);
}
if (SourceString == "red") {
return RGB(255, 0, 0);
}
if (SourceString == "blue") {
return RGB(0, 0, 255);
}
if (SourceString == "green") {
return RGB(0, 128, 0);
}
if (SourceString == "purple") {
return RGB(100, 0, 135);
}
if (SourceString == "navy") {
return RGB(0, 0, 128);
}
if (SourceString == "maroon") {
return RGB(128, 0, 0);
}
return RGB(255, 255, 255);
}