int CRollupCtrl::InsertPage(const char* caption, UINT nIDTemplate, CRuntimeClass* rtc, int idx)
{
if (idx>0 && idx>=m_PageList.GetSize()) idx=-1;
//Create Template
ASSERT(rtc!=NULL);
CDialog* wndtemplate = (CDialog*)rtc->CreateObject();
/*********************************************************************/
BOOL b = wndtemplate->Create(nIDTemplate,this);//出现内存访问错误( 0xC0000005: 读取位置 0x00000000 时发生访问冲突),什么原因????????????/**********************************************************************/
if (!b) { delete wndtemplate; return -1; }
//Insert Page
return _InsertPage(caption, wndtemplate, idx, TRUE);
}

解决方案 »

  1.   

    能够重现的错误,debug调试起来比较方便
      

  2.   


    是不是我在调用这个函数int CRollupCtrl::InsertPage(const char* caption, UINT nIDTemplate, CRuntimeClass* rtc, int idx)的时候,
    CRuntimeClass* rtc这个参数传递的有错误,然后调用CDialog* wndtemplate = (CDialog*)rtc->CreateObject() 创建对象失败,造成空指针???刚接触MFC C++编程,恳求指教。
      

  3.   

    是不是我在调用这个函数int CRollupCtrl::InsertPage(const char* caption, UINT nIDTemplate, CRuntimeClass* rtc, int idx)的时候,
    CRuntimeClass* rtc这个参数传递的有错误,然后调用CDialog* wndtemplate = (CDialog*)rtc->CreateObject() 创建对象失败,造成空指针???刚接触MFC C++编程,恳求指教。
      

  4.   


    问题解决,wndtemplate的值为NULL,利用CRuntimeClass对象的时候把DECLARE_DYNCREATE和DECLARE_DYNAMIC弄混了!!!
    谢谢帮助!!!!!!!!!!!!!!!!!!!!!!!