old drawer/C, C++, MFC

[MFC] Enter Key 종료 방지

A.Step 2012. 11. 14. 09:41

1. 원하는 다이얼로그에서 재정의를 클릭

 

2. PreTranslateMessage를 재정의한다고 하고

 

 

 

 

3. 원하는 메시지를 먹어버리면 됨... 여기서는 엔터키를 그냥 삼켰음.

 

BOOL CSocketTestDlg::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 ){
            return TRUE;
        }
    }

    return CDialog::PreTranslateMessage(pMsg);
}