使用子类化技术,让 对话框中的 Edit 控件接受 TAB 键(纯属抄袭MSDN)
2005-10-28 09:59
441 查看
The following example shows how to subclass an instance of an edit control in a dialog box. The subclass window procedure enables the edit control to receive all keyboard input, including the ENTER and TAB keys, whenever the control has the input focus.
WNDPROC wpOrigEditProc; LRESULT APIENTRY EditBoxProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hwndEdit; switch(uMsg) { case WM_INITDIALOG: // Retrieve the handle to the edit control. hwndEdit = GetDlgItem(hwndDlg, ID_EDIT); // Subclass the edit control. wpOrigEditProc = (WNDPROC) SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG) EditSubclassProc); // // Continue the initialization procedure. // return TRUE; case WM_DESTROY: // Remove the subclass from the edit control. SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG) wpOrigEditProc); // // Continue the cleanup procedure. // break; } return FALSE; UNREFERENCED_PARAMETER(lParam); } // Subclass procedure LRESULT APIENTRY EditSubclassProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_GETDLGCODE) return DLGC_WANTALLKEYS; return CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam); }
相关文章推荐
- MFC 对话框中tab控件的使用
- MFC中 使用Tab Control 控件在对话框中添加属性页
- vc 对话框使用Tab Control控件的多标签页
- VC2010 Tab控件使用
- 使用Android Support Design 控件TabLayout 方便快捷实现选项卡功能
- Android中使用Tablayout自定义tab不能填充父控件的问题
- DevExpress 使用 XtraTabbedMdiManager 控件以 Tab样式加载 Mdi窗体并合并 RibbonControl 解决方案
- 25,Tabpanel控件使用
- 如何使对话框中edit控件的滚动条始终在最底部
- MFC中如何修改对话框中控件的TAB顺序
- MFC对话框使用标签页控件
- MFC:Tab Control 控件的使用
- VC++ Tab Control 控件使用简介
- EasySize使用笔记(对话框中的控件随着对话框大小的变化进行自动调整)
- Tab Control控件简单使用
- 黑马程序员——IOS学习四:基础控件Label,textfield,button等使用——黑马 ios 技术博客
- Android之EditText控件使用
- 使用对话框和控件
- 安卓Design包之TabLayout控件的使用
- 关于对话框OnInitDialog里设置edit控件输入焦点问题