如何将mfc中单文本,对话框,列表框控件内的数据导出到txt文本?
至于获得文本框、列表框的数据,各有各的方法,最简单的是映射一个CString的成员变量。
char* pszFileName="C:\\myfile.txt";
CStdioFile myFile;
CFileException fileException;
if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite),&fileException)
{
myFile.WriteString(字符串);
}
else
{
TRACE("Can't open file %s,error=%u\n",pszFileName,fileException.m_cause);
}
GetItemText获取Listctrl中的各个元素的字符串数据,然后在fwrite写入文件
int nSel = m_ListBox_Content.GetSelCount();
CArray< int,int& > arrayListSel;
arrayListSel.SetSize(nSel);
m_ListBox_Content.GetSelItems(nSel,arrayListSel.GetData());
CString s = _T("");
for( int i=0; i< nSel; i++ )
{
m_ListBox_Content.GetText( arrayListSel[i], s);
myFile.WriteString(s);
}
不知道为什么History这个txt文档就是不断的说未定义?
History在哪里定义的。