treesummaryrefslogcommitdiff
path: root/src/win.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/win.h')
-rw-r--r--src/win.h27
1 files changed, 23 insertions, 4 deletions
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 <windows.h>
#include <CommCtrl.h>
@@ -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<void(HWND, UINT, WPARAM, LPARAM)>>> handlers;
+ struct Timer {
+ bool active = true;
+ std::function<void()> f;
+ };
+ std::vector<Timer> 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<void()> 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