Listing 2

handle_event on_rclick() {
  menu<owned> rclick_mnu(IDR_my_app);
  menu<shared> mnu = rclick_mnu.sub_menu(0);
  // set the menu text for Add/Edit Employee commands
  mnu.item_byid(ID_new_empl, menuitem_info().text("Add " + role));
  mnu.item_byid(ID_edit_empl, menuitem_info().text("Edit " + role));
  // erase the Del Employee command, if we don't have any...
  if ( m_employees.empty())
      mnu.del_item_byid( ID_del_empl);
  // Append last modified employees
  int count = mnu.item_count();
  empl_array::iterator begin = m_last_empls.begin();
  for ( ; begin != m_last_empls.end(); ++begin) 
      mnu.insert_bypos(count++, menuitem_info().text( begin->name));
  mnu.run_popup( cursor_pos(), window());
  return event<WM_RBUTTONDOWN>().HANDLED_BY(&me::on_rclick);
}