C++语言 无法通过Esc键关闭窗体

BOOL CWelcomeDlg::PreTranslateMessage(MSG* pMsg) //Called to filter messages before they are dispatched
{
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->message == WM_KEYDOWN && pMsg->wParam == 27)
    {
        CString s;
        s.Format("The wParam= %d The message = %d", pMsg->wParam, pMsg->message);
        MessageBox(s);
        return NULL;
    }
    return CDialog::PreTranslateMessage(pMsg);
}
在消息调用之前的函数
原文地址:https://www.cnblogs.com/pythonschool/p/2770102.html