关于打开另外一种文档的问题!

xiaqq 2001-12-26 11:09:15
我现在有个程序是一个多文档的程序,在程序运行中需要打开另外一种序列化的文档,假设这种文档类型为CDocumentA,序列化的结构知道,我需要从这中文档中读取一些信息,应该使用什么样的方法?
我使用下面的方法出错了(win2000下没有出错,win98下出错):
CDocumentA *pDocTmp;
pDocTmp= new CDocument;
pDocTmp->OnOpenDocument(FilePath);
使用对象也是同样的出错!

...全文
114 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
pinel 2001-12-31
  • 打赏
  • 举报
回复
多谢,您太慷慨了
xiaqq 2001-12-30
  • 打赏
  • 举报
回复
给分!
总的说来我也不知道出了什么问题!
换了另一台机器就好了!
呵呵
xiaqq 2001-12-27
  • 打赏
  • 举报
回复
现在只要我使用new就会出错!
不知道为什么?
xiaqq 2001-12-26
  • 打赏
  • 举报
回复
解决了的话,给你300分!
呵呵
xiaqq 2001-12-26
  • 打赏
  • 举报
回复
如果序列化是:
ar<<BList;
我要取得BList,怎么办?
pinel 2001-12-26
  • 打赏
  • 举报
回复
你不是知道序列化的结构吗?
如果store的形式是
ar<<BList.A<<BList.B;
那么load的形式就是
ar>>Blist.A>>BList.B
当然只是个形式,因为能够序列化的类型只有标准变量类型(int,float等)和CObject,
所以load出来的是东西(标准类型)必须手工加入事先生成的同类型连表(BList.AddTail())
xiaqq 2001-12-26
  • 打赏
  • 举报
回复
pinel():
说的详细一点,比如文档中的一个链表BList如何获得?
pinel 2001-12-26
  • 打赏
  • 举报
回复
阿东 : 圣诞节出去玩了吗
pinel 2001-12-26
  • 打赏
  • 举报
回复
CFile file;
int ret=0;
ret=file.Open(sysconfig_file, CFile::shareExclusive | CFile::modeRead);
if(ret==0)
return;
//////////Load
CArchive ar(&file, CArchive::load);
ar>>变量



xiaqq 2001-12-26
  • 打赏
  • 举报
回复
不需要new ?
使用CWinApp的OpenDocumentFile()也会出错!
dongfa 2001-12-26
  • 打赏
  • 举报
回复
pDocTmp= new CDocumentA
pinel 2001-12-26
  • 打赏
  • 举报
回复

DocTmp->OnOpenDocument(CurDir+"\\"+FileName+".ACCP");
这里报错了吗?还是调试进去看看吧
很难说是什么错

m_ElementList在CEDocument::Serialize()中应该有序列化代码,你在Serialize()中也设断点,不一定和莲表有关

win2000,和98对文件操作有什么不同我也不太清楚,可能帮不了你,抱歉。下班要回家了


xiaqq 2001-12-26
  • 打赏
  • 举报
回复
//获得要显示的点的信息
POINTINFO CAhmpView::GetPointInfo(CString PointName)
{
POINTINFO PointInfoTmp;
CString PointTmp;
CString ModuName;
CString IOPointName;
CString CurDir;
CString FileName;
BOOL m_bNoFind=TRUE;

PointInfoTmp.fPointHL=100.0;
PointInfoTmp.fPointLL=0.0;
PointInfoTmp.sPointDesc="";
PointInfoTmp.sPointUint="";

PointTmp=PointName;
int i=PointTmp.Find(".");
PointTmp=PointTmp.Right(PointTmp.GetLength()-i-1);
ModuName=PointTmp.Left(PointTmp.Find("."));
IOPointName=PointTmp.Right(PointTmp.GetLength()-PointTmp.Find(".")-1);


CMainFrame* pMainWnd = (class CMainFrame*)AfxGetApp()->m_pMainWnd;
CurDir=m_strSysPath+"\\sysinfo\\"+pMainWnd->m_strCurPrj;

POSITION pos1=ACCPDocList.GetHeadPosition();
while(pos1 && m_bNoFind){
FileName=ACCPDocList.GetNext(pos1);
CEDocument *DocTmp;
DocTmp=new CEDocument;
DocTmp->OnOpenDocument(CurDir+"\\"+FileName+".ACCP");*/

POSITION pos2=DocTmp->m_ElementList.GetHeadPosition();
while(pos2 && m_bNoFind){
CElement* EleTmp=DocTmp->m_ElementList.GetNext(pos2);

if(EleTmp->m_Type >= ANALOG_IN_ELEMENT && EleTmp->m_Type < MAX_TYPE){
CModIO* pMIO = (CModIO*)EleTmp;
if(pMIO->m_ModName==ModuName){
PointInfoTmp.sPointDesc=pMIO->m_ModDesc;
PointInfoTmp.sPointUint=pMIO->m_Out.m_Uint;
PointInfoTmp.fPointHL=pMIO->m_Out.m_HL;
PointInfoTmp.fPointLL=pMIO->m_Out.m_LL;
m_bNoFind=FALSE;
}
}

//不为输入输出模块图元
else if(EleTmp->m_Type >= ADD_ELEMENT && EleTmp->m_Type < ANALOG_IN_ELEMENT){
CModCommon* ModuTmp =(CModCommon*)EleTmp;
if(ModuTmp->m_ModName==ModuName){
PointInfoTmp.sPointDesc=ModuTmp->m_ModDesc;
POSITION pos3=ModuTmp->m_IOList.GetHeadPosition();
while(pos3 && m_bNoFind){
CIOPoint *pPoint=ModuTmp->m_IOList.GetNext(pos3);
if(pPoint->m_ModName==IOPointName){
PointInfoTmp.sPointUint=pPoint->m_Uint;
PointInfoTmp.fPointHL=pPoint->m_HL;
PointInfoTmp.fPointLL=pPoint->m_LL;
m_bNoFind=FALSE;
}
}
}
}

}
DocTmp->RemoveAll(); //删除文档中的链表项
delete DocTmp; //删除文档指针*/
}

return PointInfoTmp;
}
xiaqq 2001-12-26
  • 打赏
  • 举报
回复
说来话长,继承太多,结构太差!
我不做了!
就让他们在win2000下用吧!
呵呵
pinel 2001-12-26
  • 打赏
  • 举报
回复
sorry,刚睡了一觉。
如果序列化是:
ar<<BList;
那么,BList必然是派生类,并且已经实现了序列化(就是重载Serialize)
要取得BList当然是
ar>>BList

但是你能看到这个派生类的话,就不会来这提问题了,要么是我理解错了,要么是你没讲清楚,不如把代码贴出来(特别是有关BList保存的)

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧