Listing 8

struct my_class_handler : event_handler<...> {
    // ...
    // Syntax:
    handle_event my_func( [some_args]) {
       return event_I_am_handling().HANDLED_BY(&me::my_func);
    }

    // Examples:
    handle_event on_size() {
        // ...
        return event<WM_SIZE>().HANDLED_BY(&me::on_size);
    }
    handle_event on_ok() {
        // ... (button clicked)
        return command<IDOK, BN_CLICKED>().HANDLED_BY(&me::on_ok);
    }
    handle_event on_text_change() {
        // ... (the edit box text has changed)
        return notify<IDC_TEXT, EN_SELCHANGE>().HANDLED_BY(&me::on_text_change);
   }
    handle_event on_open_file() {
        // ... (a command has been issued,
        // most likely from Menu or Rightclick menu )
        return command<IDC_OPEN_FILE>().HANDLED_BY(&me::on_open_file);
    }

    // Ranges:
    handle_event on_any_text_change() {
        // ... (any edit box from IDC_TEXT01, IDC_TEXT02 ... IDC_TEXT15
        // has changed)
        return notify_range<IDC_TEXT01, IDC_TEXT15, EN_SELCHANGE>().
        HANDLED_BY(&me::on_any_text_change);
    }
    // ...
};