Listing 7

// taken from win32gui/spy/spy.cpp
struct spy_handler_before : subclass::auto_event_handler<
    spy_handler_before, window_base, events_before, INT_MIN> {
  static bool matches_wnd(window_base * w) {
     detail::scoped_lock lock(s_spy_info.cs);
     return s_spy_info.is_enabled;
  }
  // ...
  handle_event any_event(...) {
    // ...
    return event<0>().HANDLED_BY(&me::any_event);
  }
};
struct spy_handler_after : subclass::auto_event_handler<
    spy_handler_after, window_base, events_after, INT_MAX> {
  static bool matches_wnd(window_base * w) {
     detail::scoped_lock lock(s_spy_info.cs);
     return s_spy_info.is_enabled;
  }
  // ...
  handle_event any_event(...) {
    // ...
    return event<0>().HANDLED_BY(&me::any_event);
  }
};