-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFileHandlingDemo.src
201 lines (174 loc) · 6.06 KB
/
FileHandlingDemo.src
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
// 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-2002, Antwise Solutions
// ** 11-11-2002 WvA Updated code to work with the latest version of the
// vWin32fh package.
Use dfPanel.pkg
Use dfbase.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 Public ""
Property String psSelectedFolder Public ""
Property String psOperation Public ""
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
Local String sValue
Send DoSelectFile
Get psSelectedFile to sValue
Set Value Item 0 To sValue
End_Procedure // Prompt
End_Object // oSelectFile
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
Local String sValue
Send DoSelectFolder
Get psSelectedFolder To sValue
Set Value Item 0 To sValue
End_Procedure // Prompt
End_Object // oSelectFolder
Object oDone_bn Is A Button
Set Location To 50 190
Procedure Activating
Local String sOperation
Forward Send Activating
Get psOperation To sOperation
Set Label To sOperation
End_Procedure // Activating
Procedure OnClick
Send DoFileOperation
Send Close_panel
End_Procedure // OnClick
End_Object // oDone_bn
Object oCancel_bn Is A Button
Set Location To 50 135
Set Label To "Cancel"
Procedure OnClick
Send Close_panel
End_Procedure // OnClick
End_Object // oCancel_bn
Procedure DoFileOperation
Local String sSource
Local String sDestination
Local String sOperation
Local Integer iRetVal
Get psOperation To sOperation
Get psSelectedFile To sSource
Get psSelectedFolder To sDestination
If sOperation EQ "Copy" Begin
Move (vCopyFile(sSource,sDestination)) To iRetVal
If iRetVal EQ 0 Send DoEditWriteln To (oShowIt(Self)) "File copied succesfully"
End
Else If sOperation EQ "Move" Begin
Move (vMoveFile(sSource,sDestination)) To iRetVal
If iRetVal EQ 0 Send DoEditWriteln To (oShowIt(Self)) "File moved succesfully"
End
End_Procedure // DoFileOperation
Procedure DoSelectFile
Local String sSelectedFile
Local String sMsg
Move (vSelect_File("Text files|*.txt|Batch files|*.bat|System files|*.sys|All files|*.*","Select a file","C:\")) To sSelectedFile
If sSelectedFile NE "" Move ("The file"*sSelectedFile*"is Selected.") To sMsg
Else Move "No file is selected." To sMsg
Set psSelectedFile To sSelectedFile
Send DoEditWriteln To (oShowIt(Self)) sMsg
End_Procedure // DoSelectFile
Procedure DoSelectFolder
Local String sSelectedFolder
Local String sMsg
Move (vSHBrowseForFolder("Select a folder")) To sSelectedFolder
If sSelectedFolder NE "" Move ("The folder"*sSelectedFolder*"is Selected.") To sMsg
Else Move "No file is selected." To sMsg
Set psSelectedFolder To sSelectedFolder
Send DoEditWriteln To (oShowIt(Self)) sMsg
End_Procedure // DoSelectFolder
Procedure Activating
Local String sOperation
Forward Send Activating
Get psOperation To sOperation
Append sOperation "-file demonstration with Windows 32 API functions"
Set Label To sOperation
End_Procedure // Activating
End_Object // oHuppeldepup
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(Self))
End_Procedure // OnClick
End_Object // oCopy_bn
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(Self))
End_Procedure // OnClick
End_Object // oMove_bn
Object oRename_bn Is A Button
Set Location To 25 10
Set label To "Rename File"
Procedure OnClick
Local String sSelectedFile
Local String sMsg
Move "not implemented in demo, API functions are there" To sMsg
Send DoEditWriteln To (oShowIt(Self)) sMsg
End_Procedure // OnClick
End_Object // oRename_bn
Object oDelete_bn Is A Button
Set Location To 25 65
Set label To "Delete File"
Procedure OnClick
Local String sSelectedFile
Local String sMsg
Move "not implemented in demo, API functions are there" To sMsg
Send DoEditWriteln To (oShowIt(Self)) sMsg
End_Procedure // OnClick
End_Object // oDelete_bn
Object oDDE_bn Is A Button
Set Location To 25 120
Set label To "Dance"
Procedure OnClick
Local String sMsg
Move "http:/" To sMsg
Append sMsg "/www.vdf-guidance.com"
Send vShellExecute "OPEN" sMsg "" ""
Send DoEditWriteln To (oShowIt(Self)) sMsg
End_Procedure // OnClick
End_Object // oDDE_bn
Object oShowit Is A Edit
Set Location To 45 10
Set Size To 70 175
Set Enabled_State To False
Procedure doEditWriteln String lsString
send append_text (lsString + (character(13)) + (character(10)) )
End_Procedure
End_Object // oShowit
End_Object
Send Popup To (Main(Self))
Start_UI