MFC写一个简单记事本
2016-11-21 20:31
176 查看
void CLinjtlDlg::OnClickedOpen() { // TODO: 在此添加控件通知处理程序代码 CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"ALL Files(*.TXT)|*.TXT||",AfxGetMainWnd()); CString strPath,strText=""; if(dlg.DoModal()==IDOK) { strPath =dlg.GetPathName(); m_OP.SetWindowText(strPath); CFile file(strPath,CFile::modeRead); char read[10000]; file.Read(read,10000); for(int i=0;i<file.GetLength();i++) { strText+=read[i]; } file.Close(); m_Edit1.SetWindowText(strText); } } void CLinjtlDlg::OnBnClickedSave() { // TODO: 在此添加控件通知处理程序代码 CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"ALL Files(*.TXT)|*.TXT||",AfxGetMainWnd()); CString strPath,strText=""; char write[1000]; if(dlg.DoModal()==IDOK) { strPath=dlg.GetPathName(); if(strPath.Right(4)!=".txt") strPath+=".txt"; m_SP.SetWindowText(strPath); CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite); m_Edit1.GetWindowText(strText); strcpy(write,strText); file.Write(write,strText.GetLength()); file.Close(); }
相关文章推荐
- 一个简单的统计代码行数的程序(基于MFC)
- 一个最简单的MFC程序
- MFC 程序最小化到系统托盘区的一个简单实例 .
- 代码---模拟一个简单的记事本
- MFC下创建一个简单的窗口
- 『Visual C++ MFC 简明教程』----第二部分:一个简单的MFC程序
- win32sdk学习 richedit实现的一个简单记事本
- 一个简单的MFC中TreeView使用
- 一个最简单的MFC程序框架剖析
- 一个mfc实现的简单计算功能
- [置顶] MFC 程序最小化到系统托盘区的一个简单实例
- Visual C++ MFC 简明教程2:一个简单的MFC程序
- MFC:一个最简单的例子
- MFC 程序最小化到系统托盘区的一个简单实例
- 一个简单的Win32程序(不用MFC)
- 在MFC下使用OpenGL的一个简单的例子
- 一个最简单的MFC程序
- 在MFC下使用OpenGL的一个简单的例子(基于单文档程序)
- java编写一个简单记事本
- MFC中ClistCtrl控件的insertIterm()一个简单用法