本文介绍了丰富的Edit控件保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用丰富的编辑控件为C ++创建文本编辑器.
我使用CFileDialog将Rich编辑中的代码保存到* .cpp或* .h文件中.当我保存它,然后在Visual C ++环境中打开它时,它向我显示行尾消息,并且在每行代码之间放置一个空行.
我该如何解决?
Hi,
I''m making a text editor for C++ using rich edit control.
I use CFileDialog to save the code in Rich edit to a *.cpp or *.h file.
When I save it and then open it with Visual C++ environment, it shows me Line endings message and it puts an empty line between every line of code.
How can I fix it?
Thanks in advance!
推荐答案
CFileDialog dlg(FALSE, NULL, NULL, OFN_OVERWRITEPROMPT,
L"C++ Source Files (*.cpp)|*.cpp|C++ Header Files (*.h)|*.h|");
CStdioFile file;
CString buffer;
CString textfile;
if(dlg.DoModal() == IDOK)
{
file.Open(dlg.GetPathName(), // more appropriate instead of GetFileName()
CFile::typeBinary | CStdioFile::modeCreate | CStdioFile::modeWrite);
text.GetWindowText(buffer);
file.Write((void*)(LPCTSTR)buffer, buffer.GetLength() * sizeof(TCHAR));
file.Close();
}
您不会为上述代码的UNICODE转换做任何事情.如果您没有将项目设置更改为MBCS,则保存的文件仍应为UNICODE.
You aren''t doing anything for UNICODE conversion with above code. If you didn''t change project settings to MBCS, saved file should still be UNICODE.
这篇关于丰富的Edit控件保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!