-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunction.cpp
More file actions
56 lines (40 loc) · 1.2 KB
/
Function.cpp
File metadata and controls
56 lines (40 loc) · 1.2 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
#include"RefreshRate.h"
App::App() {
glfwInitHint(GLFW_VERSION_MAJOR, 4);
glfwInitHint(GLFW_VERSION_MINOR, 3);
if (glfwInit() == GLFW_FALSE) {
std::cout << "Impossibile inizializzare opengl" << std::endl;
exit(EXIT_FAILURE);
}
this->running = true;
this->nid = {};
nid.cbSize = sizeof(nid);
nid.hWnd = GetDesktopWindow();
nid.uFlags = NIF_ICON | NIF_TIP;
nid.hIcon = (HICON)LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_SHARED);
int val = this->getRefreshRate();
std::wstring V = std::to_wstring(val);
memcpy(this->nid.szTip, V.c_str(), 128);
Shell_NotifyIcon(NIM_ADD, &nid);
}
App::~App() {
Shell_NotifyIcon(NIM_DELETE, &this->nid);
glfwTerminate();
}
void App::mainLoop() {
int val = 0;
std::wstring V = L"";
while (this->running) {
Sleep(5000);
val = this->getRefreshRate();
V = std::to_wstring(val);
memcpy(this->nid.szTip, V.c_str(), 128);
Shell_NotifyIcon(NIM_MODIFY, &this->nid);
}
}
int App::getRefreshRate() {
int count = 0;
GLFWmonitor** monitor = glfwGetMonitors(&count);
GLFWvidmode *videomode = const_cast<GLFWvidmode*>(glfwGetVideoMode(monitor[0]));
return videomode->refreshRate;
}