Last changed 1995.02.01
//To exit a modal TDialog by pressing a //TButton hat does not send cmExit, cmQuit //or equivalent but sends cmSearch instead, and //to call another TDialog. TVDialog::TVDialog () : TDialog (...), TWindowInit (...) { // other stuff insert (new TButton (TRect(40,20,50,22), "~S~earch", cmSearch, bfDefault) ); selectNext (False); }; //There are two ways to do this //1) Overload the handleEvent function in TVDialog void TVDialog::handleEvent(TEvent& ev) { if (ev.what == evCommand && ev.message.command == cmSearch) { clearEvent(ev); ev.message.comand = cmOk; // change event to one that will exit searchFlag = 1; // set a flag or somehow note cmSearch event } TDialog::handleEvent(ev); } //2) Overload the handleEvent, but as follows: void TVDialog::handleEvent(TEvent& ev) { if (ev.what == evCommand && ev.message.command == cmSearch) { endModal(ev.message.command); clearEvent(ev); } else TDialog::handleEvent(ev); }