X-Git-Url: https://gitweb.ps.run/autorec/blobdiff_plain/8d3cfb2ed7f4d2a70832526e1a2a68926e8a8d4b..81f259240d157ddcb0cb692826855d7505f4a22f:/src/win.h diff --git a/src/win.h b/src/win.h index b8763ea..0a734c9 100644 --- a/src/win.h +++ b/src/win.h @@ -1,7 +1,3 @@ -#pragma comment(linker, "\"/manifestdependency:type='win32' \ -name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ -processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - #include #include @@ -42,6 +38,10 @@ namespace win { SetWindowLongPtrA(hwnd, GWL_STYLE, getStyle() & (~style)); } + void setActive(bool active) + { + EnableWindow(hwnd, active); + } }; struct Window : Hwnd { @@ -95,6 +95,12 @@ namespace win std::vector< std::function>> handlers; + struct Timer { + bool active = true; + std::function f; + }; + std::vector timers; + Window(std::string title, std::string className, HINSTANCE hInstance) { WNDCLASSEXA wc; @@ -155,6 +161,19 @@ namespace win }, 0); } + void setTimer(UINT interval, std::function cb) + { + SetTimer(this->hwnd, timers.size() + 1000, interval, [](HWND hwnd, UINT uMsg, UINT_PTR uIdEvent, DWORD dwTime) { + Window *window = (Window*)GetWindowLongPtrA(hwnd, 0); + if (window == nullptr) + return; + + window->timers[uIdEvent-1000].f(); + }); + Timer t; + t.f = cb; + timers.push_back(t); + } }; struct Button : Hwnd