Revision: 20124
Updated Code
at June 21, 2010 13:07 by jimfred
Updated Code
// 1st approach. http://msdn.microsoft.com/en-us/magazine/cc301409.aspx BEGIN_MESSAGE_MAP(CMyDlg, CDialog) ON_MESSAGE(DM_GETDEFID, OnGetDefID) .... END_MESSAGE_MAP() LRESULT CMyDlg::OnGetDefID(WPARAM wp, LPARAM lp) { return MAKELONG(0,DC_HASDEFID); } // 2nd approach. BOOL DialogName::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_KEYDOWN) { if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) { pMsg->wParam=NULL ; } } return CDialog::PreTranslateMessage(pMsg); }
Revision: 20123
Updated Code
at June 21, 2010 13:04 by jimfred
Updated Code
// 1st approach. BEGIN_MESSAGE_MAP(CMyDlg, CDialog) ON_MESSAGE(DM_GETDEFID, OnGetDefID) .... END_MESSAGE_MAP() LRESULT CMyDlg::OnGetDefID(WPARAM wp, LPARAM lp) { return MAKELONG(0,DC_HASDEFID); } // 2nd approach. BOOL DialogName::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_KEYDOWN) { if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) { pMsg->wParam=NULL ; } } return CDialog::PreTranslateMessage(pMsg); }
Revision: 20122
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 8, 2009 09:22 by jimfred
Initial Code
BOOL DialogName::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_KEYDOWN) { if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) { pMsg->wParam=NULL ; } } return CDialog::PreTranslateMessage(pMsg); }
Initial URL
http://www.codersource.net/mfc_dialog_message.html
Initial Description
Initial Title
MFC, How to avoid closing of the dialog boxes when ESCAPE key or ENTER key is pressed.
Initial Tags
Initial Language
C++