Home > Software engineering >  Realizing the function of "save as" how do you write the code
Realizing the function of "save as" how do you write the code

Time:10-06

MFC dialog-based applications, to create a button
Void CMoveEnterDlg: : the save ()
{
}
Add the function of the code implementation:
Achieve click the button "save as" the function, and then save the path in the edit box (namely Edit2), according to



How to write this???????

CodePudding user response:

"Save as" is the logical thing, here is you choose to save the path, and then back to choose the path set edit text,

 BOOL isOpen=FALSE;//whether open (or save) 
Cstrings defaultDir=L "E: \ \ FileTest";//the default file path
Cstrings fileName=L "test. Doc";//the default file name
Cstrings filter=L "file (*.doc; *. PPT; *. XLS) | *. Doc; *. PPT; *. XLS | | ";//the type of file filter
CFileDialog openFileDlg (isOpen, defaultDir, fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, NULL);
OpenFileDlg. GetOFN (.) lpstrInitialDir=L "E: \ \ FileTest \ \ test doc";
INT_PTR result=openFileDlg. DoModal ();
Cstrings filePath=defaultDir + "\ " + fileName;
If (result==IDOK) {
FilePath.=openFileDlg GetPathName ();
}
}

CodePudding user response:

Save as is to open a file dialog box, get a filename to save, and then save,
  • Related