作者在 2009-02-23 10:29:18 发布以下内容
void Ctest108Dlg::OnBnClickedButton2()//打开功能
{
CFileDialog dlg(TRUE);
if(IDOK==dlg.DoModal())
{
CFile file(dlg.GetFileName(),CFile::modeRead);
char *buf;
UINT dwfileleth;
dwfileleth=(UINT)file.GetLength();
buf=new char[dwfileleth+1];
buf[dwfileleth]=0;
file.Read(buf,dwfileleth);
file.Close();
SetDlgItemText(IDC_EDIT2,buf);
}
}
{
CFileDialog dlg(TRUE);
if(IDOK==dlg.DoModal())
{
CFile file(dlg.GetFileName(),CFile::modeRead);
char *buf;
UINT dwfileleth;
dwfileleth=(UINT)file.GetLength();
buf=new char[dwfileleth+1];
buf[dwfileleth]=0;
file.Read(buf,dwfileleth);
file.Close();
SetDlgItemText(IDC_EDIT2,buf);
}
}
void Ctest108Dlg::OnBnClickedButton3()//保存功能
{
CFileDialog dlg(FALSE);
if(dlg.DoModal())
{
CFile file(dlg.GetFileName(),CFile::modeWrite|CFile::modeCreate);
CString str;
GetDlgItemText(IDC_EDIT2,str);
file.Write(str.GetBuffer(str.GetLength()),str.GetLength());
file.Close();
}
}
{
CFileDialog dlg(FALSE);
if(dlg.DoModal())
{
CFile file(dlg.GetFileName(),CFile::modeWrite|CFile::modeCreate);
CString str;
GetDlgItemText(IDC_EDIT2,str);
file.Write(str.GetBuffer(str.GetLength()),str.GetLength());
file.Close();
}
}