The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Class TUnivSaveDialog


An often encountered situation when using a "file save" dialog is when the user enters or selects a file which already exists. In this case the user has to be asked whether he/she wants to overwrite the existing file, or enter another name, or cancel the dialog. The standard save dialog of Delphi or C++Builder does not account for overwriting. This situation is mastered by the class TUnivSaveDialog, which is a universal customizable save dialog.

The following diagram shows the flow of control when calling the method Execute. First of all, the "file select" dialog is called via the event OnFileSelect. In this dialog the user enters or selects a file name. If the property UseStandardDialog is set TRUE, the standard save dialog is displayed as the file select dialog instead of issuing the event OnFileSelect.

Next, it is checked whether the user tries to store the file in a forbidden directory. If so, the event OnForbiddenDir is triggered which allows to react to this situation.

In the third phase (if the user selected file in a non-forbidden directory), the "file check" function is called. This function returns TRUE if the entered file name already exists. Again, if the property UseStandardDialog is TRUE, the FileExists function (unit SysUtils of Delphi) is automatically called, otherwise the OnFileCheck event is triggered.

Finally, if the file already exists, the OnOverwrite event is triggered which can be used to ask the user whether to overwrite the file. As an option the user may cancel the entire dialog at this point. Please note that files are always overwritten if the OnOverwrite event is left unassigned (this is not shown in flow control diagram).


Last Update: 2023-Feb-06