Dialog EditBox에서 엔터키 처리

Dialog에서는 Edit에서 Enter키를 Want Return을 지정하더라도 Enter키 입력시 다이어로그가 종료된다.

1. PreTranslateMessage(MSG* pMsg)를 다음과 같이 오버라이드 한다.
2. 엔터키 입력시 원하는 처리를 각각 추가 한다.

BOOL CHMC_CleanerDlg::PreTranslateMessage(MSG* pMsg)
{
 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
 {      
  if (GetDlgItem(IDC_EDIT1) == GetFocus())
  {
   return TRUE;
  }
  if (GetDlgItem(IDC_EDIT2) == GetFocus())
  {
   // 여기에 추가
   return TRUE;
  }
  if (GetDlgItem(IDC_EDIT4) == GetFocus())
  {
   // 여기에 추가
   return TRUE;
  }
 }
 return CDialog::PreTranslateMessage(pMsg);
}

 

답글 남기기

이메일 주소는 공개되지 않습니다.