// Get control type CtrlType centerview :: getCtrltype (CWND * PWND) {charf [512]; cstract sztmp; // Define enumeration type ENUM CTLTYPE {EditType, // Edit box Buttype, // button Othertype // Other} Add a protection method to this base class: if (pWnd! = Null) {:: getClassName (pWnd-> getsafehwnd (), buf, 512); sztmp.trimright (); if (sztmp == " Edit ") return EditType; else if (szTmp ==" Button ") return ButtonType; else return OtherType;} else return OtherType;} BOOL CENTERView :: PreTranslateMessage (MSG * pMsg) {// TODO: in this specific code and adding / Or call the base class IF (PMSG-> Message == wm_keydown) {CWND * pctrl = null; switch (pmsg-> wparam) {case vk_escape: // shield ESC RETURN TRUE; Case VK_RETURN: {PCTRL = GetFocus (); // If the current control is a button to change the IF (get TRLTYPE (PCTR) == Buttype) {:: seundMessage (pctrl-> getsafehwnd (), wm_lbuttondown, 0, 0); :: sendMessage (PCTRL- > Getsafehwnd (), wm_lbuttonup, 0, 0);}} (getCtrltype (PCTRL)! = Othertype) getNextdlgTabItem (PCTRL) -> setfocus (); returntrue;} default: Break;