forked from olaeld/vwin32fh
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileHandlingDemo.src
More file actions
216 lines (190 loc) · 6.85 KB
/
FileHandlingDemo.src
File metadata and controls
216 lines (190 loc) · 6.85 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// This code is part of «VDF GUIdance»
// Visit us @ http://www.vdf-guidance.com
// e-Mail us @ info@vdf-guidance.com
// VDF GUIdance is a mutual project of
// Frank Vandervelpen - Vandervelpen Systems and
// Wil van Antwerpen - Antwise Solutions
// All software source code should be used «AS IS» without any warranty.
// Author: Wil van Antwerpen
//
// (c) 1999-2018, Antwise Solutions
// ** 11-11-2002 WvA Updated code to work with the latest version of the
// vWin32fh package.
// ** 06-06-2018 WvA Updated code to have no warnings on DF19.1
Use Windows.pkg
Use dfPanel.pkg
Use vWin32fh.pkg
// This is a small demoprogram on how to use the API functions.
// It doesn't show all the functionality of the vWin32fh package, but you will
// get the basic idea.
Register_Object oShowIt
Object Main is a Panel
Set Label to "Windows File-handling Demo"
Set Size to 165 200
Property String psSelectedFile ""
Property String psSelectedFolder ""
Property String psOperation ""
Object oHuppeldepup is a modalpanel
Set Size to 95 250
Object oSelectFile is a form
Set Location to 10 70
Set Size to 13 170
Set Label to "Select file"
Set Prompt_Button_Mode to PB_PromptOn
Set form_Button_Bitmap Item 0 to "ABNew.bmp"
Procedure Prompt
String sValue
Send DoSelectFile
Get psSelectedFile to sValue
Set Value Item 0 to sValue
End_Procedure
End_Object
Object oSelectFolder is a form
Set Location to 30 70
Set Size to 13 170
Set Label to "Select folder"
Set Prompt_Button_Mode to PB_PromptOn
Set form_Button_Bitmap Item 0 to "OpenFold.bmp"
Procedure Prompt
String sValue
Send DoSelectFolder
Get psSelectedFolder to sValue
Set Value Item 0 to sValue
End_Procedure
End_Object
Object oDone_bn is a Button
Set Location to 50 190
Procedure Activating
String sOperation
Forward Send Activating
Get psOperation to sOperation
Set Label to sOperation
End_Procedure
Procedure OnClick
Send DoFileOperation
Send Close_Panel
End_Procedure
End_Object
Object oCancel_bn is a Button
Set Location to 50 135
Set Label to "Cancel"
Procedure OnClick
Send Close_Panel
End_Procedure
End_Object
Procedure DoFileOperation
String sSource
String sDestination
String sOperation
Integer iRetVal
Get psOperation to sOperation
Get psSelectedFile to sSource
Get psSelectedFolder to sDestination
If (sOperation = "Copy") Begin
Move (vCopyFile(sSource,sDestination)) to iRetVal
If (iRetVal = 0) ;
Send DoEditWriteln to oShowIt "File copied succesfully"
End
Else If (sOperation = "Move") Begin
Move (vMoveFile(sSource,sDestination)) to iRetVal
If (iRetVal = 0) ;
Send DoEditWriteln to oShowIt "File moved succesfully"
End
Else If (sOperation = "Delete") Begin
Move (vDeleteFile(sSource)) to iRetVal
If (iRetVal = 0) ;
Send DoEditWriteln to oShowIt "File deleted succesfully"
End
End_Procedure
Procedure DoSelectFile
String sSelectedFile
String sMsg
Move (vSelect_File("Text files|*.txt|Batch files|*.bat|System files|*.sys|All files|*.*","Select a file","C:\")) to sSelectedFile
If (sSelectedFile <> "") ;
Move ("The file"*sSelectedFile*"is Selected.") to sMsg
Else ;
Move "No file is selected." to sMsg
Set psSelectedFile to sSelectedFile
Send DoEditWriteln to oShowIt sMsg
End_Procedure
Procedure DoSelectFolder
String sSelectedFolder
String sMsg
Move (vSHBrowseForFolder("Select a folder")) to sSelectedFolder
If (sSelectedFolder <> "") ;
Move ("The folder"*sSelectedFolder*"is Selected.") to sMsg
Else ;
Move "No file is selected." to sMsg
Set psSelectedFolder to sSelectedFolder
Send DoEditWriteln to oShowIt sMsg
End_Procedure
Procedure Popup
String sOperation
Get psOperation to sOperation
If (sOperation="Delete") Begin
Set Visible_State of oSelectFolder to False
Set Enabled_State of oSelectFolder to False
End
Else Begin
Set Visible_State of oSelectFolder to True
Set Enabled_State of oSelectFolder to True
End
Append sOperation " - file demonstration with Windows 32 API functions"
Set Label to sOperation
Forward Send Popup
End_Procedure
End_Object
Object oCopy_bn is a Button
Set Location to 10 10
Set Label to "Copy File"
Procedure OnClick
Set psOperation to "Copy"
Send Popup to oHuppeldepup
End_Procedure
End_Object
Object oMove_bn is a Button
Set Location to 10 65
Set Label to "Move File"
Procedure OnClick
Set psOperation to "Move"
Send Popup to oHuppeldepup
End_Procedure
End_Object
Object oRename_bn is a Button
Set Location to 25 10
Set Label to "Rename File"
Procedure OnClick
String sMsg
Move "not implemented in demo, API functions are there" to sMsg
Send DoEditWriteln to oShowIt sMsg
End_Procedure
End_Object
Object oDelete_bn is a Button
Set Location to 25 65
Set Label to "Delete File"
Procedure OnClick
Set psOperation to "Delete"
Send Popup to oHuppeldepup
End_Procedure
End_Object
Object oDDE_bn is a Button
Set Location to 25 120
Set Label to "Dance"
Procedure OnClick
String sMsg
Move "https://www.vdf-guidance.com" to sMsg
Send vShellExecute "OPEN" sMsg "" ""
Send DoEditWriteln to oShowIt sMsg
End_Procedure
End_Object
Object oShowit is a Edit
Set Location to 45 10
Set Size to 70 175
Set Enabled_State to False
Procedure doEditWriteln String sText
Send append_text (sText + (Character(13)) + (Character(10)) )
End_Procedure
End_Object
End_Object
Send Popup to (Main(Self))
Start_UI