-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
92 lines (77 loc) · 2.3 KB
/
main.cpp
File metadata and controls
92 lines (77 loc) · 2.3 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <vector>
#include "GUIDs.hpp"
#include "Device.hpp"
#include "Monitor.hpp"
std::string ErrorMessage(std::uint32_t Error)
{
LPTSTR lpMsgBuf = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, NULL);
return lpMsgBuf;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static std::vector<Device> devs;
switch(msg)
{
case WM_CREATE:
{
devs.emplace_back(Device(hwnd, devices[3]));
}
break;
case WM_DEVICECHANGE:
{
DEV_BROADCAST_DEVICEINTERFACE* info = (DEV_BROADCAST_DEVICEINTERFACE*) lParam;
switch(wParam)
{
case DBT_DEVICEARRIVAL:
MonitorDisplay().Clone();
std::cout<<MonitorDisplay().Name(info)<<" Connected.\n";
std::cout<<"Set Cloned Display.\n\n";
break;
case DBT_DEVICEREMOVECOMPLETE:
MonitorDisplay().Internal();
std::cout<<MonitorDisplay().Name(info)<<" Disconnected.\n";
std::cout<<"Set Internal Display.\n\n";
break;
default:
std::cout<<"wParam: "<<(void*)wParam<<"\n";
break;
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int Create()
{
WNDCLASSEX wx = {0};
wx.cbSize = sizeof(WNDCLASSEX);
wx.lpfnWndProc = WndProc;
wx.hInstance = GetModuleHandle(NULL);
wx.lpszClassName = "HDMI_MONITOR";
if (RegisterClassEx(&wx))
{
MSG msg = {0};
CreateWindowEx(0, "HDMI_MONITOR", "HDMI_MONITOR", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
return 0;
}
int main()
{
MonitorDisplay().TurnOff();
Sleep(1000);
MonitorDisplay().TurnOn();
//return Create();
}