forked from olaeld/vwin32fh
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcvFileDialogs.pkg
More file actions
91 lines (76 loc) · 3.01 KB
/
cvFileDialogs.pkg
File metadata and controls
91 lines (76 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//***************************************************************************
//*
//* 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