mfc对话框禁止关闭
作者:互联网
禁止用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); }
标签:lParam,mfc,return,LOG,对话框,nID,pMsg,关闭 来源: https://www.cnblogs.com/zhangmo/p/14816787.html