禁止用alt+f4\esc\点击关闭按钮关闭对话框
void UpdateChoice::OnSysCommand(UINT nID, LPARAM lParam) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nID == SC_CLOSE) { LOG_S("ScClose is Pressed"); } else { CDialogEx::OnSysCommand(nID, lParam); } } BOOL UpdateChoice::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if (pMsg->message == WM_KEYDOWN) { if (pMsg->wParam == VK_ESCAPE) { LOG_S("EscKey is Prevented"); return TRUE; } if (pMsg->wParam == VK_RETURN) { LOG_S("EntKey is Pressed"); //return TRUE; } } return CDialogEx::PreTranslateMessage(pMsg); }