home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
QBAS
/
VBUTIL.ZIP
/
FILEOPEN.DOC
< prev
next >
Wrap
Text File
|
1992-10-19
|
4KB
|
143 lines
Sub cboFiletype_Click ()
Select Case cboFiletype.ListIndex
Case 0 ' Text Files (*.txt)
NewPattern = "*.txt"
Case 1 ' All Files (*.*)
NewPattern = "*.*"
End Select
txtFileName.Text = NewPattern
filFiles.Pattern = NewPattern
' reinitialize the file controls
filFiles.Refresh
End Sub
Sub cmdcancel_Click ()
' Set the file name text box to null.
' By checking the text property of this text box,
' other procedures can tell if Cancel has been
' selected.
FileForm.txtFileName.Text = Empty
' Hide the form
FileForm.Hide
End Sub
Sub cmdOK_Click ()
Dim Msg As String
On Error Resume Next
If txtFileName.Text Like "*[;>]*" Or txtFileName.Text Like "*[ ,+|/]*" Then
Msg = "Bad filename"
' Display error and select the offending text.
MsgBox Msg, 48, App.EXEName
txtFileName.SetFocus
txtFileName.SelStart = 0
txtFileName.SelLength = Len(txtFileName.Text)
Else
Hide
End If
End Sub
Sub dirDirs_Change ()
' propogate directory changes to other controls
filFiles.Path = dirDirs.Path
lblCurrentDir.Caption = dirDirs.Path
ChDir dirDirs.Path
txtFileName.Text = filFiles.Pattern
End Sub
Sub drvDrives_Change ()
' change the dirDirs control path, it will
' pass the change on to the filFiles control
dirDirs.Path = drvDrives.Drive
ChDrive (drvDrives.Drive)
End Sub
Sub filFiles_Click ()
' echo the selected name in the Text box
txtFileName.Text = filFiles.FileName
End Sub
Sub filFiles_DblClick ()
' we have a final selection from the File Save dialog
'txtFilename.Text = filFiles.FileName
cmdOK_Click
End Sub
Sub filFiles_PathChange ()
dirDirs.Path = filFiles.Path
drvDrives.Drive = filFiles.Path
End Sub
Sub filFiles_PatternChange ()
'Show the current search pattern in the txtFileName control
txtFileName.Text = filFiles.Pattern
dirDirs.Path = filFiles.Path
End Sub
Sub Form_Activate ()
' If File Open dialog, set Text box to current pattern
If FileForm.Caption = "Open" Then
txtFileName.Text = filFiles.Pattern
End If
' If a File Save dialog, set the text box
' to the current file name
If FileForm.Caption = "Save As" Then
' File is not named
If frmMDI.ActiveForm.Caption = "Untitled" Then
FileForm.txtFileName.Text = filFiles.Pattern
' File has a name
Else
FileForm.txtFileName.Text = frmMDI.ActiveForm.Caption
End If
End If
' initialize file controls
filFiles.Refresh
' Clear current selection in Filetype list box
cboFiletype.ListIndex = -1
' Set FileType list box to first item (*.txt)
cboFiletype.ListIndex = 0
' highlight the current selection
FileForm.txtFileName.SelStart = 0
FileForm.txtFileName.SelLength = Len(FileForm.txtFileName.Text)
End Sub
Sub Form_Load ()
' display full path name in a label
lblCurrentDir.Caption = dirDirs.Path
' add items to List Files of Type list
cboFiletype.AddItem "Text Files (*.txt)"
cboFiletype.AddItem "All Files (*.*)"
End Sub
Sub Form_Unload (Cancel As Integer)
Cancel = True ' Don't unload form, just hide it
Call cmdcancel_Click
End Sub
Sub txtFileName_Change ()
' Disable OK button if no filename.
cmdOK.Enabled = (Len(txtFileName.Text) > 0)
End Sub