home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 13 / CD_ASCQ_13_0494.iso / maj / 1697 / samples / fileopen.frm < prev    next >
Text File  |  1992-10-20  |  7KB  |  261 lines

  1. VERSION 2.00
  2. Begin Form FileForm 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "File Form"
  5.    ControlBox      =   0   'False
  6.    FontBold        =   -1  'True
  7.    FontItalic      =   0   'False
  8.    FontName        =   "System"
  9.    FontSize        =   9.75
  10.    FontStrikethru  =   0   'False
  11.    FontUnderline   =   0   'False
  12.    Height          =   3510
  13.    Icon            =   FILEOPEN.FRX:0000
  14.    Left            =   1485
  15.    LinkMode        =   1  'Source
  16.    LinkTopic       =   "Form1"
  17.    MaxButton       =   0   'False
  18.    MinButton       =   0   'False
  19.    ScaleHeight     =   3105
  20.    ScaleWidth      =   5640
  21.    Top             =   1605
  22.    Width           =   5760
  23.    Begin CommandButton cmdOk 
  24.       Caption         =   "OK"
  25.       Default         =   -1  'True
  26.       Height          =   420
  27.       Left            =   4320
  28.       TabIndex        =   8
  29.       Top             =   120
  30.       Width           =   1125
  31.    End
  32.    Begin TextBox txtFileName 
  33.       Height          =   375
  34.       Left            =   240
  35.       TabIndex        =   1
  36.       Text            =   "*.txt"
  37.       Top             =   360
  38.       Width           =   1575
  39.    End
  40.    Begin CommandButton cmdCancel 
  41.       Cancel          =   -1  'True
  42.       Caption         =   "Cancel"
  43.       Height          =   420
  44.       Left            =   4320
  45.       TabIndex        =   9
  46.       Top             =   720
  47.       Width           =   1125
  48.    End
  49.    Begin FileListBox filFiles 
  50.       Height          =   1395
  51.       Left            =   240
  52.       Pattern         =   "*.txt"
  53.       TabIndex        =   2
  54.       Top             =   840
  55.       Width           =   1620
  56.    End
  57.    Begin DirListBox dirDirs 
  58.       Height          =   1425
  59.       Left            =   2040
  60.       TabIndex        =   5
  61.       Top             =   840
  62.       Width           =   2100
  63.    End
  64.    Begin ComboBox cboFiletype 
  65.       Height          =   300
  66.       Left            =   240
  67.       Style           =   2  'Dropdown List
  68.       TabIndex        =   12
  69.       Top             =   2640
  70.       Width           =   1695
  71.    End
  72.    Begin DriveListBox drvDrives 
  73.       Height          =   1530
  74.       Left            =   2040
  75.       TabIndex        =   7
  76.       Top             =   2640
  77.       Width           =   2115
  78.    End
  79.    Begin Label Label1 
  80.       Caption         =   "List Files of &Type:"
  81.       Height          =   255
  82.       Left            =   240
  83.       TabIndex        =   11
  84.       Top             =   2400
  85.       Width           =   1695
  86.    End
  87.    Begin Label lblFileName 
  88.       Caption         =   "File &Name:"
  89.       Height          =   240
  90.       Left            =   240
  91.       TabIndex        =   0
  92.       Top             =   120
  93.       Width           =   1200
  94.    End
  95.    Begin Label lblDirectories 
  96.       Caption         =   "&Directories:"
  97.       Height          =   240
  98.       Left            =   2040
  99.       TabIndex        =   3
  100.       Top             =   150
  101.       Width           =   1200
  102.    End
  103.    Begin Label lblCurrentDir 
  104.       Height          =   225
  105.       Left            =   2040
  106.       TabIndex        =   4
  107.       Top             =   480
  108.       Width           =   2085
  109.    End
  110.    Begin Label lblDrives 
  111.       Caption         =   "Dri&ves:"
  112.       Height          =   255
  113.       Left            =   2040
  114.       TabIndex        =   6
  115.       Top             =   2400
  116.       Width           =   765
  117.    End
  118. End
  119.  
  120. Sub cboFiletype_Click ()
  121.     Select Case cboFiletype.ListIndex
  122.         Case 0      ' Text Files (*.txt)
  123.             NewPattern = "*.txt"
  124.         Case 1      ' All Files (*.*)
  125.             NewPattern = "*.*"
  126.     End Select
  127.     
  128.     txtFileName.Text = NewPattern
  129.     filFiles.Pattern = NewPattern
  130.     ' reinitialize the file controls
  131.     filFiles.Refresh
  132. End Sub
  133.  
  134. Sub cmdcancel_Click ()
  135.     
  136.     ' Set the file name text box to null.
  137.     ' By checking the text property of this text box,
  138.     ' other procedures can tell if Cancel has been
  139.     ' selected.
  140.     FileForm.txtFileName.Text = Empty
  141.     
  142.     ' Hide the form
  143.     FileForm.Hide
  144.  
  145. End Sub
  146.  
  147. Sub cmdOK_Click ()
  148. Dim Msg As String
  149. On Error Resume Next
  150.     If txtFileName.Text Like "*[;>]*" Or txtFileName.Text Like "*[ ,+|/]*" Then
  151.         Msg = "Bad filename"
  152.         ' Display error and select the offending text.
  153.         MsgBox Msg, 48, App.EXEName
  154.         txtFileName.SetFocus
  155.         txtFileName.SelStart = 0
  156.         txtFileName.SelLength = Len(txtFileName.Text)
  157.     Else
  158.         Hide
  159.     End If
  160.  
  161. End Sub
  162.  
  163. Sub dirDirs_Change ()
  164.     
  165.     ' propogate directory changes to other controls
  166.     filFiles.Path = dirDirs.Path
  167.     lblCurrentDir.Caption = dirDirs.Path
  168.     ChDir dirDirs.Path
  169.     txtFileName.Text = filFiles.Pattern
  170.  
  171. End Sub
  172.  
  173. Sub drvDrives_Change ()
  174.  
  175.     ' change the dirDirs control path, it will
  176.     ' pass the change on to the filFiles control
  177.     dirDirs.Path = drvDrives.Drive
  178.     ChDrive (drvDrives.Drive)
  179.  
  180. End Sub
  181.  
  182. Sub filFiles_Click ()
  183.     
  184.     ' echo the selected name in the Text box
  185.     txtFileName.Text = filFiles.FileName
  186.  
  187. End Sub
  188.  
  189. Sub filFiles_DblClick ()
  190.  
  191.     ' we have a final selection from the File Save dialog
  192.     'txtFilename.Text = filFiles.FileName
  193.     cmdOK_Click
  194.  
  195. End Sub
  196.  
  197. Sub filFiles_PathChange ()
  198.     dirDirs.Path = filFiles.Path
  199.     drvDrives.Drive = filFiles.Path
  200. End Sub
  201.  
  202. Sub filFiles_PatternChange ()
  203.     'Show the current search pattern in the txtFileName control
  204.     txtFileName.Text = filFiles.Pattern
  205.     dirDirs.Path = filFiles.Path
  206. End Sub
  207.  
  208. Sub Form_Activate ()
  209.     ' If File Open dialog, set Text box to current pattern
  210.     If FileForm.Caption = "Open" Then
  211.         txtFileName.Text = filFiles.Pattern
  212.     End If
  213.     
  214.     ' If a File Save dialog, set the text box
  215.     ' to the current file name
  216.     If FileForm.Caption = "Save As" Then
  217.         ' File is not named
  218.         If frmMDI.ActiveForm.Caption = "Untitled" Then
  219.             FileForm.txtFileName.Text = filFiles.Pattern
  220.         ' File has a name
  221.         Else
  222.             FileForm.txtFileName.Text = frmMDI.ActiveForm.Caption
  223.     End If
  224.     
  225.     End If
  226.     ' initialize file controls
  227.     filFiles.Refresh
  228.     
  229.     ' Clear current selection in Filetype list box
  230.     cboFiletype.ListIndex = -1
  231.     
  232.     ' Set FileType list box to first item (*.txt)
  233.     cboFiletype.ListIndex = 0
  234.     
  235.     ' highlight the current selection
  236.     FileForm.txtFileName.SelStart = 0
  237.     FileForm.txtFileName.SelLength = Len(FileForm.txtFileName.Text)
  238.  
  239. End Sub
  240.  
  241. Sub Form_Load ()
  242.     ' display full path name in a label
  243.     lblCurrentDir.Caption = dirDirs.Path
  244.  
  245.     ' add items to List Files of Type list
  246.     cboFiletype.AddItem "Text Files (*.txt)"
  247.     cboFiletype.AddItem "All Files (*.*)"
  248. End Sub
  249.  
  250. Sub Form_Unload (Cancel As Integer)
  251.     
  252.     Cancel = True   ' Don't unload form, just hide it
  253.     Call cmdcancel_Click
  254. End Sub
  255.  
  256. Sub txtFileName_Change ()
  257.     ' Disable OK button if no filename.
  258.     cmdOK.Enabled = (Len(txtFileName.Text) > 0)
  259. End Sub
  260.  
  261.