各位大虾~~小弟是打算这样子的:打开一个选择文件对话框,选了几个文件之后,后台打开文件,处理完后,自动关闭文件。
代码如下所示。
但是在下面的while循环中,调用了一次OnCloseDocument()之后再次循环调OnOpenDocument()就会出现错误:
Unhandled exception in CoinRecognize.exe:0xC0000005:Accesse Violation. 我单步调试,发现OnOpenDocument()并没有进入意料中的函数,而是跳到了_AFX_INLINE CString::operator LPCTSTR() const
{ return m_pchData; }程序代码:
void CCoinRecognizeDoc::OnReadTFiles()
{
CString str;
CStdioFile file;
CString temps; //为了调用view中的函数
POSITION POS=GetFirstViewPosition();
CCoinRecognizeView* pView= (CCoinRecognizeView*)GetNextView(POS); CFileDialog fd(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,"BMP Files(*.bmp)|*.bmp");
fd.DoModal();
POSITION filepos;
filepos=fd.GetStartPosition();
if(!file.Open("src.txt",CFile::modeCreate|CFile::modeWrite))return; while(filepos!=NULL)
{
str=fd.GetNextPathName(filepos);
OnOpenDocument(str); ///此处打开文档 ///*以下是自己的写的数据处理函数*//// pView-> OnOneKeyRht();
temps=formatData(pView->temp.x,pView->temp.y,pView->temp.radius);
file.WriteString(temps); //////////////////////////////////// OnCloseDocument();//此处关闭文档
} file.Close();
AfxMessageBox("succesed!");
}哪位大哥能告诉我个究竟啊……难道不可以这样关闭的么?
在线等……
代码如下所示。
但是在下面的while循环中,调用了一次OnCloseDocument()之后再次循环调OnOpenDocument()就会出现错误:
Unhandled exception in CoinRecognize.exe:0xC0000005:Accesse Violation. 我单步调试,发现OnOpenDocument()并没有进入意料中的函数,而是跳到了_AFX_INLINE CString::operator LPCTSTR() const
{ return m_pchData; }程序代码:
void CCoinRecognizeDoc::OnReadTFiles()
{
CString str;
CStdioFile file;
CString temps; //为了调用view中的函数
POSITION POS=GetFirstViewPosition();
CCoinRecognizeView* pView= (CCoinRecognizeView*)GetNextView(POS); CFileDialog fd(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,"BMP Files(*.bmp)|*.bmp");
fd.DoModal();
POSITION filepos;
filepos=fd.GetStartPosition();
if(!file.Open("src.txt",CFile::modeCreate|CFile::modeWrite))return; while(filepos!=NULL)
{
str=fd.GetNextPathName(filepos);
OnOpenDocument(str); ///此处打开文档 ///*以下是自己的写的数据处理函数*//// pView-> OnOneKeyRht();
temps=formatData(pView->temp.x,pView->temp.y,pView->temp.radius);
file.WriteString(temps); //////////////////////////////////// OnCloseDocument();//此处关闭文档
} file.Close();
AfxMessageBox("succesed!");
}哪位大哥能告诉我个究竟啊……难道不可以这样关闭的么?
在线等……
解决方案 »
- VFW摄像头抓帧,摄像头插在不同USB抓取的图像大小不同?
- 关于STDAFX.H中添加别的头文件出现LNK2005错误的问题,请高手出招,谢谢!
- 当点中CDialog空白区域的问题.
- 如何Radio、Combo等控件实现ReadOnly效果
- Vista下使用CreateProcessAsUser新建进程的问题
- 一个关于format drive的简单问题
- 为什么不能控制系统重起?
- 关于对话框上面按钮的问题,一个菜鸟很菜的问题,在线等,马上结贴
- vc++ double 除法的问题
- 一个 Write 线程和多个 Read 线程之间的同步
- DataGrid如何获取当前选中行中某一项的数据
- 在VC中如何使用PNG文件
CDocument::OnCloseDocument
virtual void OnCloseDocument( );ResCalled by the framework when the document is closed, typically as part of the File Close command. The default implementation of this function destroys all of the frames used for viewing the document, closes the view, cleans up the document's contents, and then calls the DeleteContents member function to delete the document’s data.
再声明一个CFile fileRead
专门用来读文件
我还是自己写了自己的OpenDocument和CloseDocument函数……
谢谢各位的参与……
膜拜,离场……