• 您的位置我爱Aspx >> VC.Net >> 走出MFC子类化的迷宫
  • 走出MFC子类化的迷宫

  • 作者:aspxer  来源:internet  日期:2007-5-21 23:49:05  关键字:
  • return FALSE; // control not found

    }

    代码开始时对传入的父窗口做些检查,然后就是

    HWND hWndControl = ::GetDlgItem(pParent->m_hWnd, nID);

    if (hWndControl != NULL)

    return SubclassWindow(hWndControl);

    这是关键的代码,先用hWndControl得到我们IDC_EDIT1控件的句柄,然后调用

    SubclassWindow函数,这个函数是实现的关键,我们来看一下它做了什么:

    BOOL CWnd::SubclassWindow(HWND hWnd)

    {

    if (!Attach(hWnd)) return FALSE;

    // allow any other subclassing to occur

    PreSubclassWindow();

    // now hook into the AFX WndProc

    WNDPROC* lplpfn = GetSuperWndProcAddr();

    WNDPROC oldWndProc = (WNDPROC)::SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)AfxGetAfxWndProc());

    ASSERT(oldWndProc != (WNDPROC)AfxGetAfxWndProc());

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:传递自动化字符串数组
    下一篇:C#和C++的速度大比拼(二)
  • 相关文章