首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

求函数指针的准确使用!

2013-03-01 
求函数指针的正确使用!!!!“DDX_Control”: 不能将参数 3 从“CEdit *(__cdecl *)(CEdit *)”转换为“CWnd &”我

求函数指针的正确使用!!!!



“DDX_Control”: 不能将参数 3 从“CEdit *(__cdecl *)(CEdit *)”转换为“CWnd &”
我是想dll中封装的类指针与资源绑定呀

typedef CEdit* (*lpCall)(CEdit*);


CEdit* ExportCEdit(CEdit* pParam)
{
    return new CEdit();
}

lpCall pFunc = ExportCEdit;


DDX_Control(pDX, IDC_EDIT1, pFunc);

[解决办法]
typedef CEdit* (*lpCall)(CWnd*);
[解决办法]
写一个基于指针的 DDX_Control 或者直接使用 SubclassWindow


void AFXAPI DDX_Control(CDataExchange* pDX, int nIDC, CWnd *rControl)
{
  if (rControl && rControl->m_hWnd == NULL)    // not subclassed yet
  {
    ASSERT(!pDX->m_bSaveAndValidate);
    
    HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
    
    if (!rControl->SubclassWindow(hWndCtrl))
    {
      ASSERT(FALSE);      // possibly trying to subclass twice?
      AfxThrowNotSupportedException();
    }
#ifndef _AFX_NO_OCC_SUPPORT
    else
    {
      // If the control has reparented itself (e.g., invisible control),
      // make sure that the CWnd gets properly wired to its control site.
      if (pDX->m_pDlgWnd->m_hWnd != ::GetParent(rControl->m_hWnd))
        rControl->AttachControlSite(pDX->m_pDlgWnd);
    }
#endif //!_AFX_NO_OCC_SUPPORT
    
  }
}


热点排行