Prevent Enter and Esc close dialog program
来源:互联网 发布:机智的监狱生活 知乎 编辑:程序博客网 时间:2024/06/05 17:01
Well there are also many way, such as Override the OnOK() and OnCancel().
The easier and more powerful way is to Overrides the function PreTranslateMessage() in the dialog class.
BOOL CServerSocketDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN || nVirtKey == VK_RETURN) { int nVirtKey = (int) pMsg->wParam; if (nVirtKey == VK_ESCAPE) return TRUE; } return CDialog::PreTranslateMessage(pMsg); }
But in this way all Enter key pressed event will be disabled, if wanna press Enter to click a button, we can add extra code:
// CButton m_ctlMessage if (nVirtKey == VK_RETURN && (GetFocus()->m_hWnd == m_ctlMessage.m_hWnd)) { // this is the CButton function OnBnClickedButton1(); return TRUE; }
- Prevent Enter and Esc close dialog program
- 屏蔽Dialog对话框中的Esc和Enter键的思路
- MFC Dialog 屏蔽Enter和Esc按下时自动退出程序
- [MFC]学习笔记:Dialog 屏蔽Enter & ESC退出的功能
- Preventing "Return" and "Esc" From Closing Dialog
- MFC 屏蔽 ESC ENTER
- VC 屏蔽ESC,ENTER
- VC屏蔽Enter和ESC
- 屏蔽Enter或是Esc键
- MFC窗口响应Enter/Esc
- MVVM: Good way to close dialog and set DialogResult
- Dialog屏蔽Esc按键
- please remove installation media and close the tray (if any) then press ENTER
- 禁止对话框的enter 和 ESC 按钮
- 屏蔽ENTER键、ESC键的使用
- javascript 判断按下健是enter或Esc
- 屏蔽Enter键和Esc键
- VC屏蔽Enter和ESC退出程序
- 计算几何学库函数
- 跪请众朋友帮我找下问题出在哪里?--3
- 数据仓库工作总结
- 跪请众朋友帮我找下问题出在哪里?--4
- 正则表达式 ((/w*|(/w/s*/w*)*)(/w*/S))$ ((/w*|(/w/s*(.)*/w*)*)(/w*/S))$ .net 前后去掉(没有)空格
- Prevent Enter and Esc close dialog program
- usaco 3.4 Closed Fences 计算几何
- 用Java动态代理实现AOP
- 使用ScriptControl令程序增加脚本功能
- GridView中修改TextBox模板列的寬度
- 《上帝掷骰子吗:量子物理史话》读后感
- MyGeneration13.01界面问题解决
- Edit控件密码窗口的秘密--一种全新的通用密码记录技术
- 封装ASP.NET操作ACCESS数据库常用操作的类