C++编译的文本编辑器
}
CString strText=""; SavePath = str;
int n = SavePath.ReverseFind('.');
CString stl = SavePath.Right(SavePath.GetLength() - n - 1);
if (stl == "txt" || stl == "TXT" || stl == "c" || stl == "C" || stl == { } else {
MessageBox ("不支持的文件类型!","打开错误");
int Choice = MessageBox("当前文本已被修改,想保存吗?","系统提示", MB_YESNO|MB_ICONQUESTION); //弹出消息对话框询问 if(Choice==IDYES) //选择“是” { }
OnMenuSave();//调用保存函数保存文件
"cpp" || stl == "CPP"
|| stl == "h" || stl == "H" || stl == "xml" || stl == "XML" || stl
== "html" || stl == "HTML")
CFile file(str,CFile::modeReadWrite); //以读与写方式打开文件 //m_Edit.SetSel(0, -1); //全部选中文本内容 m_Edit.Clear();//将所有文本删除 char read[50000];
file.Read(read,50000); //读取文件内容 for(unsigned i=0;i<file.GetLength();i++) {
strText += read[i]; //把文件内容赋值给CString变量
}
拖入打开
file.Close();//关闭文件 m_Edit.SetWindowText(strText); isNew = FALSE; //标记为打开文本
m_Edit.SetModify(FALSE); //文本修改标记设为修改