Listing 3

// bitmap_button.h
struct bitmap_button : ... {
  void bitmap(int id);
  void icon(int id);
  ...
};

// bitmap_button.cpp
struct wm_set_bitmap : unique_event<wm_set_bitmap> {
  wm_set_bitmap(int id, bool is) : id(id), is_bmp(is) {}
  // the resource ID of the bitmap
  int id;
  // if true, it's a bitmap; else, it's an icon
  bool is_bmp;
};

struct bitmap_button_handler 
  : event_handler<bitmap_button_handler, bitmap_button> {

  handle_event set_bmp(wm_set_bitmap::arg a) {
    if ( a->is_bmp) ...;
    else ...;
    return event_ex<wm_set_bitmap>().HANDLED_BY(&me::set_bmp);
  }
  ...
};

void bitmap_button::bitmap(int id) {
  send_event( wm_set_bitmap(id,true) );
}
void bitmap_button::icon(int id) {
  send_event( wm_set_bitmap(id,false) );
}