打开文件 read to CString str, 
text_ctrl.SetWindowText( str )

解决方案 »

  1.   

    使用CStdioFile打开文本型文件,使用ReadString函数读出每一行字符串并赋于一CString变量,最后使用Edit的setwindowtext函数显示text
      

  2.   


    1.生成一个名为Readtxt的对话类型工程
    2.在对话框里添加一个edit控件,用classwizard添加一个控件型变量m_ctledit
    3.在对话框里添加一个button控件,将caption设为Readtxt,双击,添加入下代码
    void CReadtxtDlg::OnRead() 
    {
    // TODO: Add your control notification handler code here
    CString m_strText,m_strTemp;
    CStdioFile stdfile;
    CFileException e;
    stdfile.Open("d:\\mft.txt",CFile::modeRead,&e);
    while(stdfile.ReadString(m_strTemp))
    {
    m_strText+=m_strTemp;
    }
    stdfile.Close();
    m_ctledit.SetWindowText(m_strText);
    UpdateData(TRUE);
    }
    4。在d盘生成一个mft.txt文件
    5.编译连接,运行
    6。give me scores,please
    7.如果需要工程文件,请发email到[email protected]