-#pragma comment(linker, "\"/manifestdependency:type='win32' \\r
-name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \\r
-processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")\r
-\r
#include <windows.h>\r
#include <CommCtrl.h>\r
\r
{\r
SetWindowLongPtrA(hwnd, GWL_STYLE, getStyle() & (~style));\r
}\r
+ void setActive(bool active)\r
+ {\r
+ EnableWindow(hwnd, active);\r
+ }\r
};\r
struct Window : Hwnd\r
{\r
std::vector<\r
std::function<void(HWND, UINT, WPARAM, LPARAM)>>> handlers;\r
\r
+ struct Timer {\r
+ bool active = true;\r
+ std::function<void()> f;\r
+ };\r
+ std::vector<Timer> timers;\r
+\r
Window(std::string title, std::string className, HINSTANCE hInstance)\r
{\r
WNDCLASSEXA wc;\r
},\r
0);\r
}\r
+ void setTimer(UINT interval, std::function<void()> cb)\r
+ {\r
+ SetTimer(this->hwnd, timers.size() + 1000, interval, [](HWND hwnd, UINT uMsg, UINT_PTR uIdEvent, DWORD dwTime) {\r
+ Window *window = (Window*)GetWindowLongPtrA(hwnd, 0);\r
+ if (window == nullptr)\r
+ return;\r
+\r
+ window->timers[uIdEvent-1000].f();\r
+ });\r
+ Timer t;\r
+ t.f = cb;\r
+ timers.push_back(t);\r
+ }\r
};\r
\r
struct Button : Hwnd\r