错误提示如下: WenziDialog.cpp C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2039: 'open' : is not a member of 'CStdioFile' d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile' C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2653: 'cfile' : is not a class or namespace name C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2065: 'modewrite' : undeclared identifier C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(58) : error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'class CString *' to 'class CString &' A reference that is not to 'const' cannot be bound to a non-lvalue C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(59) : error C2039: 'write' : is not a member of 'CStdioFile' d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile' C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(59) : error C2039: 'getlength' : is not a member of 'CString' d:\program files\vc98\mfc\include\afx.h(368) : see declaration of 'CString' C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(60) : error C2039: 'close' : is not a member of 'CStdioFile' d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile' Generating Code... Error executing cl.exe.Caixin.exe - 7 error(s), 0 warning(s) 我直接在保存按纽下写的.没有,我的编辑框变量是m_edit,我都给过了.是什么原因呢?多多指教!
您好,我看到你这程序,对我非常有用,我有些问题想向你请教一下!谢谢了!我按照您的程序编译之后出现了一些问题,如下: error C2653: 'cfile' : is not a class or namespace name error C2065: 'modeReadWrite' : undeclared identifier error C2065: 'm_Edit' : undeclared identifier error C2228: left of '.GetWindowTextA' must have class/struct/union type error C2039: 'close' : is not a member of 'CStdioFile'谢谢您的指导了!
1,读编辑框内容
2,写文件.第一步可以给编辑框关联变量,然后用UpdateData(),也可以用GetDlgItemText(...);
第二步可以用fstream, CFile.只作个提示
file.open("D:\\1.txt",cfile::modewrite);
CString str = _T("");
m_Edit.GetWindowText(&str);//编辑框控件的control的绑定变量
file.write(str,str.getlength());
file.close();
CStdioFile file;
file.open("D:\\1.txt",cfile::modewrite);
CString str = _T("");
m_Edit.GetWindowText(&str);//编辑框控件的control的绑定变量
file.write(str,str.getlength());
file.close();
classwizzad里,对该按纽控件双击加响应函数.为什么老提示有未定义的东西.能细说一下吗?
WenziDialog.cpp
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2039: 'open' : is not a member of 'CStdioFile'
d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile'
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2653: 'cfile' : is not a class or namespace name
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(56) : error C2065: 'modewrite' : undeclared identifier
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(58) : error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'class CString *' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(59) : error C2039: 'write' : is not a member of 'CStdioFile'
d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile'
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(59) : error C2039: 'getlength' : is not a member of 'CString'
d:\program files\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
C:\Documents and Settings\acer\桌面\Caixin\WenziDialog.cpp(60) : error C2039: 'close' : is not a member of 'CStdioFile'
d:\program files\vc98\mfc\include\afx.h(1309) : see declaration of 'CStdioFile'
Generating Code...
Error executing cl.exe.Caixin.exe - 7 error(s), 0 warning(s)
我直接在保存按纽下写的.没有,我的编辑框变量是m_edit,我都给过了.是什么原因呢?多多指教!
1.open应改为Open
2.modewrite应改为modeReadWrite
3.GetWindowText(&str)应为GetWindowText(str)
4.write(str,str.getlength())应为Write(str,str.GetLength());
呵呵,都是些小问题,但也要注意大小写呀!还不错了,分到手了吧?
error C2653: 'cfile' : is not a class or namespace name
error C2065: 'modeReadWrite' : undeclared identifier
error C2065: 'm_Edit' : undeclared identifier
error C2228: left of '.GetWindowTextA' must have class/struct/union type
error C2039: 'close' : is not a member of 'CStdioFile'谢谢您的指导了!