假设有一个链表(CTypedPtrList) m_list ,存放有从CObject继承下来的一个类CClassA指针,在exe程序中可以使用m_list.Serialize(ar)正常通过,但是同样的代码在Activex控件中串行化时出错,报错代码0xE06D7363,求朋友们指点路。

解决方案 »

  1.   

    感谢楼上的兄弟新建了一个MFC的Activex工程,其控件名为CTstOcxListSerializeCtrl
    1、在CTstOcxListSerializeCtrl的头文件中定义如下
    typedef CTypedPtrList<CObList,CCstSysParam *> CSysList;
    CSysList m_ListSysParam;
      其中CCstSysParam是一个从CObject继承下来的类,有自己的Serialize函数
    2、我在CTstOcxListSerializeCtrl的鼠标右击事件中调用TestSerialize()函数,结果错.
    3、我在其它事件中调用TestSerialize(),还是错
    4、我...没法了
    5、各位,感激不尽
    BOOL CTstOcxListSerializeCtrl::TestSerialize()
    {
    CFile file = NULL;
    BOOL bRtnVlu = TRUE;
    CFileException fe = NULL;
    CString strFile = _T("d:\\tst\dddd.ffd"); bRtnVlu = file.Open(CStringToLPCTSTR(strFile), CFile::modeCreate | CFile::modeWrite | CFile::typeBinary ,&fe);
    if (!bRtnVlu)
    {
    CString strShow = _T("");
    fe.GetErrorMessage(CStringToLPCTSTR(strShow),255);
    TRACE(_T("\n Open File Error:[%s]Error msg is:%s\n"),strFile,strShow);
    return FALSE;
    }

    CString strTest = _T("this is a test");
    CArchive ar(&file,CArchive::store);

    if(ar.IsStoring())
    {
    CCstSysParam *psys = NULL;
    psys = new CCstSysParam;
    psys->m_nFlashWindowOption = 1;
    m_ListSysParam.AddTail(psys);
    psys = new CCstSysParam;
    psys->m_nFlashWindowOption = 2;
    m_ListSysParam.AddTail(psys);
    psys = new CCstSysParam;
    psys->m_nFlashWindowOption = 3;
    m_ListSysParam.AddTail(psys);
    ar<<strTest;

    }
    else
    {
       ar>>strTest;
    }
    bRtnVlu = TRUE;
    try
    {
    m_ListSysParam.Serialize(ar); //出错了,真是晕啊晕!
    }
    catch (...)
    {
    bRtnVlu = FALSE;
    }
    if(file != NULL)
    {
    ar.Close();
    file.Close();
    } POSITION pos = m_ListSysParam.GetHeadPosition();
    while(pos)
    {
    delete m_ListSysParam.GetNext(pos);
    }
    m_ListSysParam.RemoveAll();

    return bRtnVlu;
    }备注:serialize其它类常用简单类型均不会出错
      

  2.   

    你确定是Activex中使用的问题吗?有没有在其它地方先测试你的代码:如新建一个对话框程序来Serialize你的类,看是否运行正常不要告诉我你的CCstSysParam类头文件中没加DECLARE_SERIALIZE(CCstSysParam),CPP文件中也没加IMPLIMENT_SERIALIZE(CCstSysParam,CObject,0)