MFC创建读取txt文档Dialog

来源:互联网 发布:网络教育包过 编辑:程序博客网 时间:2024/04/28 03:51
void COpenTxt::OnFileopen() //COpenTxt为新建Dialog类,OnFileopen为打开文档的按钮
{


CFileDialog fileDlg(TRUE); 
if(fileDlg.DoModal() == IDOK) 

CString str; 
CFile f; 
f.Open(fileDlg.GetFileName(),CFile::modeReadWrite); 
f.Read(str.GetBuffer(f.GetLength()),f.GetLength()); 
f.Close(); 
//MessageBox("打开成功!","提示",MB_OK);
GetDlgItem( IDC_SEND )->SetWindowText( str); //IDC_SEND为编辑文本框,输出文本


}
0 0
原创粉丝点击