文件——》打开——》弹出对话选择对话框后,代码要怎么写才可以完成以下功能:文件选定判断,文件读取后显示在edit box控件内CString strText;
strText = "Text Files(*.dat)|*.dat|All Filse(*.*)|*.*||";
CFileDialog dlgfileopen(true,"dat",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,strText);
int structsize =0;
DWORD dwVersion,dwWindowsMAjorVersion,dwWindowsMinorVersion;
dwVersion =GetVersion();
dwWindowsMAjorVersion =(DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion =(DWORD)(HIBYTE(LOWORD(dwVersion)));
if(dwVersion<0x80000000)
structsize =88;
else
structsize =76;
dlgfileopen.m_ofn.lStructSize =structsize;
TCHAR lpstrFilename[MAX_PATH] ="";
dlgfileopen.m_ofn.lpstrFile =lpstrFilename;
if(dlgfileopen.DoModal()==IDOK)
{
 
     CString filename;
 filename =dlgfileopen.GetPathName();
 CFile myfile;
 CString m_disp;
     myfile.Open("filename",CFile::modeRead);
 myfile.SeekToBegin();
 myfile.Read(m_disp.GetBufferSetLength(myfile.GetLength()),myfile.GetLength());
     GetDlgItem(IDC_EDIT1)->SetWindowText(m_disp);//在文本框中显示
}else
MessageBox("dasdsadsa");}
不知道怎么出错了的啊!
想不到!