MFC简易文本编辑器
void CeditDlg::OnBnClickedopen() { // TODO: 在此添加控件通知处理程序代码 int i=0; char s[10000]; char szFilter[]="文本文件(*.txt)|*.txt|All File(*,*)|*,*||"; CFileDialog OpenDlg(true,"*.txt",0,0,szFilter); int x=OpenDlg.DoModal(); if(x==IDOK) { CFile fileOpen; try{ fileOpen.Open(OpenDlg.GetPathName(),CFile::modeRead); i=fileOpen.GetLength(); fileOpen.Read(s,i); fileOpen.Close(); }catch(CFileException *e){ CString str; str.Format("读取数据失败的原因是:%d",e->m_cause); MessageBox(str); fileOpen.Abort(); e->Delete(); } } CString str(s,i); m_Edit1=str; UpdateData(false); } void CeditDlg::OnBnClickedsave() { // TODO: 在此添加控件通知处理程序代码 UpdateData(); char szFilter[]="文本文件(*.txt)|*.txt|All File(*,*)|*,*||"; CFileDialog SaveDlg(false,"*.txt",0,0,szFilter); int x=SaveDlg.DoModal(); if(x==IDOK) { CFile fileSave; try{ fileSave.Open(SaveDlg.GetPathName(),CFile::modeCreate|CFile::modeWrite); fileSave.Write(m_Edit1,m_Edit1.GetLength()); fileSave.Close(); }catch(CFileException *e){ CString str; str.Format("保存数据失败的原因是:%d",e->m_cause); MessageBox(str); fileSave.Abort(); e->Delete(); } } }
- 1
- 粉丝: 5
- 资源: 2
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 细胞的奇迹:吃出来的免疫力(美亚畅销书!作者的TED演讲播放量超300万次!《谷物大脑》作者、《三联生活周刊》推荐!吃下对的食物,改善你的... (Z-Library).azw3
- 智能手机产品拆解,使用mindmaster打开
- 11111111111111
- 统信系统ARM64依赖openssl-1.0.2版本的libssl.so.10和libcrypto.so.10文件
- 奥比中光python sdk
- 冯超楠17.py
- OCR识别-基于视觉注意力机制Attention实现的OCR识别算法-附项目源码-优质项目实战.zip
- Java 使用蒙特卡洛方法估算PI的近似值(源代码)
- main.cpp
- 电子木鱼小程序源码电子木鱼小程序源码