It has the following characteristics:
The file selection dialog box has the following prototypes: AFXFileSelectorDialog(form, title, fileNameKw, readOnlyKw, opts, patterns, patternIndexTgt) AFXFileSelectorDialog(parent, title, fileNameKw, readOnlyKw, opts, patterns, patternIndexTgt) You use the first constructor when you have a form associated with the dialog box that issues a command; for example, the dialog box that appears when you click Print dialog box, the user is presented with a text field to enter a file name and a button. The button posts a file selection dialog box that returns the selected file to the Print dialog box but does not issue any command. . You use the second constructor when the dialog box collects input from the user to be used in another dialog box. For example, when printing to a file from theYou must create the fileNameKw argument using the AFXStringKeyword method. Similarly, you must create the readOnlyKw argument using the AFXBoolKeyword method. If the user clicks , the file selection dialog box automatically updates the fileNameKw and readOnlyKw arguments. In addition, when the dialog box is posted, it will set the current directory based on the path of the fileNameKw argument. This means that the dialog box remembers the last directory visited by the user when the application posts the dialog box again. The following flags are available for the opts argument:
You specify the patterns argument as a series of patterns separated by \n. The value of the target specified by the patternIndexTgt argument determines which pattern is initially shown when the dialog box is posted. The following is an example of how a file selection dialog box can be posted from a form: def getFirstDialog(self): patterns = 'Output Database (*.odb)\nAll Files (*.*)' db = AFXFileSelectorDialog(self, 'Open ODB', self.nameKw, self.readOnlyKw, AFXSELECTFILE_EXISTING, patterns, self.patternIndexTgt) db.setReadOnlyPatterns('*.odb') self.setModal(True) return db The following is an example of how a directory selection dialog box can be posted from another dialog box: def onCmdDirectory(self, sender, sel, ptr): if not self.dirDb: self.dirDb = AFXFileSelectorDialog(self, 'Select a Directory',self.form.dirNameKw, None, AFXSELECTFILE_DIRECTORY) self.dirDb.create() self.dirDb.showModal() return 1 |