急,解决即散分,关于Activex控件串行化链表的问题 假设有一个链表(CTypedPtrList) m_list ,存放有从CObject继承下来的一个类CClassA指针,在exe程序中可以使用m_list.Serialize(ar)正常通过,但是同样的代码在Activex控件中串行化时出错,报错代码0xE06D7363,求朋友们指点路。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 感谢楼上的兄弟新建了一个MFC的Activex工程,其控件名为CTstOcxListSerializeCtrl1、在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其它类常用简单类型均不会出错 你确定是Activex中使用的问题吗?有没有在其它地方先测试你的代码:如新建一个对话框程序来Serialize你的类,看是否运行正常不要告诉我你的CCstSysParam类头文件中没加DECLARE_SERIALIZE(CCstSysParam),CPP文件中也没加IMPLIMENT_SERIALIZE(CCstSysParam,CObject,0) vc++开发的程序 需要用到哪些dll 如何实现用flash美化VC++编写软件的界面 编译错误 error C2678,紧急求救!!! 我取得的IP地址如何变成正确的点序 如何写以VB ActiveX EXE做进程外组件的MFC客户程序? 如何获取当前线程的句柄? 一个很麻烦的问题,求教各位高手! 请大家帮忙看看这两个问题如何解决 怎样设置基于属性表的程序的图标及最大/小化按钮? 为什么不能从CMainFrame里调用CHtmlView里的成员? 有关数字加密解密的问题 有会的大哥帮帮忙吧~~~~ 求CRC-8,G(X)=x8 + x5 + x4 + 1源码
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其它类常用简单类型均不会出错