风中的刀!

月夜寒光,风中的刀!

My Links

Blog Stats

留言簿(162)

随笔分类

随笔档案

文章档案

相册


搜索

最新评论

阅读排行榜

评论排行榜

使用子类化技术,让 对话框中的 Edit 控件接受 TAB 键(纯属抄袭MSDN)

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); 
} 

posted on 2005-10-27 16:43 风中的刀! 阅读(2255) 评论(3)  编辑 收藏

Feedback

# re: 使用子类化技术,让 对话框中的 Edit 控件接受 TAB 键(纯属抄袭MSDN) 2005-10-27 16:57 铅笔缪书

老刀终于又动刀了,收藏下

# re: 使用子类化技术,让 对话框中的 Edit 控件接受 TAB 键(纯属抄袭MSDN) 2005-10-27 21:58 freedk

刀还是老的快。。。

# re: 使用子类化技术,让 对话框中的 Edit 控件接受 TAB 键(纯属抄袭MSDN) 2008-05-27 11:13 飞凌

刀还是老的快.经典


标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]