//*************************************************************************** //* //* Class: cvSaveAsDialog //* Package Name: cvFileDialogs.pkg //* //*************************************************************************** Use File_dlg.pkg // *WvA: 13-01-1999 Created // The Class cSelectFile_Dialog is created to support the function Select_File // This function opens the Windows standard file open dialog and returns the selected // file_name. Class cvSelectFile_Dialog is an OpenDialog Procedure Construct_Object Integer iImage_Id Forward Send Construct_Object iImage_Id Set HideReadOnly_State to True End_Procedure Function SelectedFileName Returns String String sFileName Move "" to sFileName If (Show_Dialog(Self)) Begin Move (RTrim(File_Name(Self))) to sFileName End Function_Return sFileName End_Function End_Class // *WvA: 13-01-1999 Created // This function opens the Windows standard file open dialog and returns the selected // file_name. Returns '' if the user didn't make a selection. // **WvA: 17-10-2003 Cleaned up and added code to destroy the dynamically created // file-open dialog Function vSelect_File Global String sSupportedFileTypes String sCaptionText String sInitialFolder Returns String String sSelectedFile Integer hoOpenFileDialog Object oOpenFileDialog is a cvSelectFile_Dialog Set Dialog_Caption to sCaptionText Set Filter_String to sSupportedFileTypes Set Initial_Folder to sInitialFolder Move Self to hoOpenFileDialog End_Object Get SelectedFileName of hoOpenFileDialog to sSelectedFile Send Destroy_Object to hoOpenFileDialog Function_Return sSelectedFile End_Function Class cvSaveAsDialog is a SaveAsDialog Procedure Construct_Object Forward Send Construct_Object Set HideReadOnly_State to True End_Procedure Function SelectedFileName Returns String String sFileName Move "" to sFileName If (Show_Dialog(Self)) Begin Move (RTrim(File_Name(Self))) to sFileName End Function_Return sFileName End_Function End_Class // Added optional default filename as suggested by Nils Function vSelectSaveFile Global String sSupportedFileTypes String sCaptionText String sInitialFolder String sDefaultFileName Returns String String sSelectedFile Integer hoDialog Move "" to sSelectedFile Get Create (RefClass(cvSaveAsDialog)) to hoDialog If (hoDialog) Begin //Set NoChangeDir_State Of hoDialog To True Set Dialog_Caption of hoDialog to sCaptionText Set Filter_String of hoDialog to sSupportedFileTypes Set Initial_Folder of hoDialog to sInitialFolder If (Num_Arguments = 4) Begin Set File_Title of hoDialog to sDefaultFileName End Get SelectedFileName of hoDialog to sSelectedFile Send Destroy of hoDialog End Function_Return sSelectedFile End_Function