Listing 3
namespace { int monitor_timer = unique_timer_id(); }
struct monitor_move
: subclass::auto_event_handler<monitor_move,window_base> {
time_t last_move;
void on_full_create() {
window()->set_timer(monitor_timer, 1000); // each second
last_move = time(0);
}
handle_event on_timer(w_param_lo timer_id) {
if ( timer_id == monitor_timer)
if ( time(0) - last_move > 3*60) {
top_wnd<view_frame>()->show(SW_HIDE);
last_move = time(0);
}
return event<WM_TIMER>().HANDLED_BY(&me::on_timer);
}
handle_event on_key() {
last_move = time(0);
return event<WM_KEYDOWN>().HANDLED_BY(&me::on_key);
}
handle_event on_mmove() {
last_move = time(0);
return event<WM_MOUSEMOVE>().HANDLED_BY(&me::on_mmove);
}
};