CFileDialog fd (TRUE, _T (*. "obj"), NULL, 0, _T (" obj files (*. Obj) | *. Obj | | all file *. * | | "));
If (IDCANCEL.==fd DoModal ())
return;
Cstrings filename=fd. GetPathName ();
Cstrings buff.
CFile file;
if (! File. The Open (filename, CFile: : modeRead));
{
AfxMessageBox (_T (" file open failed!" ));
The return;
}
AfxMessageBox (_T (" file open success!" ));
Results:
CodePudding user response:
You don't need to reload OnFileOpen the function, because this function is MFC automatic processing,
You create an empty document, compiled some file menu to open the command, the program will pop up a file dialog
You need to reload the Serialize function!
CodePudding user response:
IsVoid CDIB: : Serialize (CArchive& Ar)
{
Ar. Flush ();
CFile * fp=ar. GetFile ();
If (ar) IsStoring ())
{
Save (fp);
}
The else
{
Load (fp);
}
}