子类化Firefox窗口下的Dialog下的EditControl

来源:互联网 发布:我要开淘宝网店 编辑:程序博客网 时间:2024/06/06 01:47

没错,你绝对没看错,是VC,在经过了选型、编译不过、再选型、库引用、链接、编译通过、写注册表、浏览器交互、ATL陷阱、CLR陷阱、MFC陷阱、找指针、绘图、定位资源、32位字符处理、父子窗口、消息传递等九九八十一道劫难后终于通过子类化让控件成功跑通了。


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


现在就剩兼容chrome和打包下载运行了,我容易吗。

原创粉丝点击