这是打开文件的代码void CReceptDBMSView::OnButtonOpen()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,"rpt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Êվݴ浵(*.rpt)|*.rpt|ËùÓÐÎļþ(*.*)|*.*||",this); if(dlg.DoModal()==IDCANCEL)
return; CString filename=dlg.GetPathName();
CString str;
CFile file; if(file.Open(filename,CFile::modeReadWrite)==0)
{
str="´ò¿ªÎļþ "+filename+" ʧ°Ü!!!";
AfxMessageBox(str);
return;
}
CArchive ar(&file,CArchive::load);
if(this->m_ReceptsCount!=0)
{
this->m_pSet->MoveFirst();
while(!this->m_pSet->IsEOF())
{
this->m_pSet->Delete();
this->m_pSet->MoveNext();
}
}
ar.Close();
file.Close(); if(AfxGetApp()->OpenDocumentFile(filename)==NULL)
AfxMessageBox("´ò¿ªÓëÊվݴ浵ͬÃûµÄÎļþʧ°Ü!!!");}
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,"rpt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Êվݴ浵(*.rpt)|*.rpt|ËùÓÐÎļþ(*.*)|*.*||",this); if(dlg.DoModal()==IDCANCEL)
return; CString filename=dlg.GetPathName();
CString str;
CFile file; if(file.Open(filename,CFile::modeReadWrite)==0)
{
str="´ò¿ªÎļþ "+filename+" ʧ°Ü!!!";
AfxMessageBox(str);
return;
}
CArchive ar(&file,CArchive::load);
if(this->m_ReceptsCount!=0)
{
this->m_pSet->MoveFirst();
while(!this->m_pSet->IsEOF())
{
this->m_pSet->Delete();
this->m_pSet->MoveNext();
}
}
ar.Close();
file.Close(); if(AfxGetApp()->OpenDocumentFile(filename)==NULL)
AfxMessageBox("´ò¿ªÓëÊվݴ浵ͬÃûµÄÎļþʧ°Ü!!!");}
解决方案 »
- 凤矶兄请进,为感谢凤矶兄而撒分,其他人顶者又分!
- GetParent应该怎么用才能访问到你类?
- 完成端口的连接问题
- 做个棋牌类型的游戏,用gdi还是directx,需要用到MFC吗?
- 用MFC写的程序采用ADO与ACCESS 在2000 下正常使用,但是在98下无法正常使用
- 想从CTreeView类派生一个新的CLeftView类,可编译后提示CTreeView类没有定义。。。
- 请问CStatic能不能设背景色和文字的颜色大小?
- 求教:scoket绑定时的问题!!!
- RASCONN这个结构体中win7中的大小是多少?
- 如何判断进程异常,各位NR.
- 有关属性页的问题
- Winsock一次能发送多大长度的数据?(TCP和UDP两种情况)
CFileDialog dlg(FALSE,...);
这样就可以了。