home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vblha1 / getfile.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  12.8 KB  |  466 lines

  1. VERSION 2.00
  2. Begin Form frmGetFile 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Select a file"
  5.    ClientHeight    =   4170
  6.    ClientLeft      =   1530
  7.    ClientTop       =   1500
  8.    ClientWidth     =   6360
  9.    Height          =   4575
  10.    Left            =   1470
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4170
  13.    ScaleWidth      =   6360
  14.    Top             =   1155
  15.    Width           =   6480
  16.    Begin PictureBox picLZHenter 
  17.       Height          =   615
  18.       Left            =   6840
  19.       Picture         =   GETFILE.FRX:0000
  20.       ScaleHeight     =   585
  21.       ScaleWidth      =   465
  22.       TabIndex        =   21
  23.       Top             =   3120
  24.       Width           =   495
  25.    End
  26.    Begin PictureBox picLZH 
  27.       BorderStyle     =   0  'None
  28.       Height          =   495
  29.       Left            =   5160
  30.       ScaleHeight     =   495
  31.       ScaleWidth      =   495
  32.       TabIndex        =   19
  33.       Top             =   3600
  34.       Width           =   495
  35.    End
  36.    Begin PictureBox picLZHopen 
  37.       Height          =   615
  38.       Left            =   6840
  39.       Picture         =   GETFILE.FRX:0302
  40.       ScaleHeight     =   585
  41.       ScaleWidth      =   465
  42.       TabIndex        =   18
  43.       Top             =   2400
  44.       Width           =   495
  45.    End
  46.    Begin PictureBox picLZHClose 
  47.       Height          =   615
  48.       Left            =   6840
  49.       Picture         =   GETFILE.FRX:0604
  50.       ScaleHeight     =   585
  51.       ScaleWidth      =   465
  52.       TabIndex        =   17
  53.       Top             =   1560
  54.       Width           =   495
  55.    End
  56.    Begin TextBox txtLZHname 
  57.       Height          =   375
  58.       Left            =   5040
  59.       TabIndex        =   16
  60.       Top             =   3120
  61.       Width           =   1215
  62.    End
  63.    Begin CommandButton btnTrash 
  64.       Caption         =   "&Trash"
  65.       Height          =   495
  66.       Left            =   5160
  67.       TabIndex        =   15
  68.       Top             =   2160
  69.       Width           =   1095
  70.    End
  71.    Begin PictureBox picFile2 
  72.       Height          =   615
  73.       Left            =   6960
  74.       Picture         =   GETFILE.FRX:0906
  75.       ScaleHeight     =   585
  76.       ScaleWidth      =   465
  77.       TabIndex        =   14
  78.       Top             =   840
  79.       Width           =   495
  80.    End
  81.    Begin PictureBox PicFile1 
  82.       Height          =   615
  83.       Left            =   6960
  84.       Picture         =   GETFILE.FRX:0C08
  85.       ScaleHeight     =   585
  86.       ScaleWidth      =   465
  87.       TabIndex        =   13
  88.       Top             =   120
  89.       Width           =   495
  90.    End
  91.    Begin CommandButton cmdDelete 
  92.       Caption         =   "&Delete"
  93.       Height          =   495
  94.       Left            =   5160
  95.       TabIndex        =   12
  96.       Top             =   1560
  97.       Width           =   1095
  98.    End
  99.    Begin CommandButton cmdCancel 
  100.       Cancel          =   -1  'True
  101.       Caption         =   "&Cancel"
  102.       Height          =   495
  103.       Left            =   5160
  104.       TabIndex        =   11
  105.       Top             =   720
  106.       Width           =   1095
  107.    End
  108.    Begin CommandButton cmdOK 
  109.       Caption         =   "&OK"
  110.       Height          =   495
  111.       Left            =   5160
  112.       TabIndex        =   10
  113.       Top             =   120
  114.       Width           =   1095
  115.    End
  116.    Begin DirListBox dirDirectory 
  117.       Height          =   2280
  118.       Left            =   2640
  119.       TabIndex        =   9
  120.       Top             =   720
  121.       Width           =   2295
  122.    End
  123.    Begin DriveListBox drvDrive 
  124.       Height          =   315
  125.       Left            =   2640
  126.       TabIndex        =   5
  127.       Top             =   3600
  128.       Width           =   2295
  129.    End
  130.    Begin ComboBox cboFileType 
  131.       Height          =   300
  132.       Left            =   240
  133.       Style           =   2  'Dropdown List
  134.       TabIndex        =   4
  135.       Top             =   3600
  136.       Width           =   2175
  137.    End
  138.    Begin FileListBox filFiles 
  139.       Height          =   2370
  140.       Hidden          =   -1  'True
  141.       Left            =   240
  142.       TabIndex        =   2
  143.       Top             =   720
  144.       Width           =   2175
  145.    End
  146.    Begin TextBox txtFileName 
  147.       Height          =   285
  148.       Left            =   240
  149.       TabIndex        =   1
  150.       Top             =   360
  151.       Width           =   2175
  152.    End
  153.    Begin Label lblLZH 
  154.       Caption         =   "LHA File Name"
  155.       Height          =   255
  156.       Left            =   5040
  157.       TabIndex        =   20
  158.       Top             =   2880
  159.       Width           =   1215
  160.    End
  161.    Begin Label lblDirName 
  162.       Height          =   255
  163.       Left            =   2640
  164.       TabIndex        =   8
  165.       Top             =   360
  166.       Width           =   1455
  167.    End
  168.    Begin Label lblDirectories 
  169.       Caption         =   "Directories:"
  170.       Height          =   255
  171.       Left            =   2640
  172.       TabIndex        =   7
  173.       Top             =   120
  174.       Width           =   975
  175.    End
  176.    Begin Label lbDrive 
  177.       Caption         =   "Drive:"
  178.       Height          =   255
  179.       Left            =   2640
  180.       TabIndex        =   6
  181.       Top             =   3360
  182.       Width           =   975
  183.    End
  184.    Begin Label lblFileType 
  185.       Caption         =   "File Type:"
  186.       Height          =   255
  187.       Left            =   240
  188.       TabIndex        =   3
  189.       Top             =   3360
  190.       Width           =   735
  191.    End
  192.    Begin Label lblFileName 
  193.       Caption         =   "File Name:"
  194.       Height          =   255
  195.       Left            =   240
  196.       TabIndex        =   0
  197.       Top             =   120
  198.       Width           =   855
  199.    End
  200. Dim LZHstatus
  201. Dim LZHname
  202. Sub btnexit_Click ()
  203. End Sub
  204. Sub btnTrash_Click ()
  205. Dim Filenum As Integer
  206. Dim Filesize As Integer
  207. On Error GoTo JDELETE
  208. If txtFileName.Text = "" Then
  209.   Exit Sub
  210. End If
  211. 'Insert drive and path name
  212. procInsPath
  213. 'Get a free file number
  214. Filenum = FreeFile
  215. 'Get file size
  216. Filesize = FileLen(frmGetFile.Tag) - 2
  217. If Filesize > 0 Then
  218. If Filesize > szbuff Then
  219.   Filesize = szbuff
  220.  End If
  221.  buffer = Space(Filesize)
  222.  'Open file
  223.  Open frmGetFile.Tag For Output As Filenum
  224.  'Output spaces to file
  225.  Print #Filenum, buffer
  226.  'Close file
  227.  Close Filenum
  228. End If
  229. JDELETE:
  230. 'Delete file
  231. Kill frmGetFile.Tag
  232. txtFileName.Text = ""
  233. 'Update file list
  234. filFiles.Refresh
  235. Exit Sub
  236. End Sub
  237. Sub btnTrash_DragDrop (Source As Control, X As Single, Y As Single)
  238. btnTrash_Click
  239. End Sub
  240. Sub btnTrash_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  241. Select Case State
  242.   Case 0
  243.     'change icon to release
  244.      filFiles.DragIcon = picFile2
  245.   Case 1
  246.     'change icon to release
  247.      filFiles.DragIcon = picFile1
  248. End Select
  249. End Sub
  250. Sub cboFileType_Click ()
  251. Dim patternpos1 As Integer
  252. Dim patternpos2 As Integer
  253. Dim patternlen As Integer
  254. Dim Pattern As String
  255. 'Find starting position
  256. patternpos1 = InStr(1, cbofiletype.Text, "(") + 1
  257. 'Find the end position
  258. patternpos2 = InStr(1, cbofiletype.Text, ")") - 1
  259. 'Calculate the length of the pattern string
  260. patternlen = patternpos2 - patternpos1 + 1
  261. 'Extract the pattern from the combo box
  262. Pattern = Mid$(cbofiletype.Text, patternpos1, patternlen)
  263. 'set the pattern of the filfiles to the select pattern
  264. filFiles.Pattern = Pattern
  265. End Sub
  266. Sub cmdCancel_Click ()
  267. 'Set the frmgetfile.tag to null
  268. frmGetFile.Tag = ""
  269. 'Hide the frmgetfile
  270. frmlha.Hide
  271. frmGetFile.Hide
  272. End Sub
  273. Sub cmdDelete_Click ()
  274. If txtFileName.Text = "" Then
  275.   Exit Sub
  276. End If
  277. 'Insert drive and path name
  278. procInsPath
  279. 'Delete file
  280. Kill frmGetFile.Tag
  281. txtFileName.Text = ""
  282. 'Update file list
  283. filFiles.Refresh
  284. End Sub
  285. Sub cmdDelete_DragDrop (Source As Control, X As Single, Y As Single)
  286. cmdDelete_Click
  287. End Sub
  288. Sub cmdDelete_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  289. Select Case State
  290.   Case 0
  291.     'change icon to release
  292.      filFiles.DragIcon = picFile2
  293.   Case 1
  294.     'change icon to release
  295.      filFiles.DragIcon = picFile1
  296. End Select
  297. End Sub
  298. Sub cmdOK_Click ()
  299. Dim pathandname As String
  300. Dim Path
  301. 'if no file is selected, exit this procedure
  302. If txtFileName.Text = "" Then
  303.   Exit Sub
  304. End If
  305. workfile.fopen = txtFileName.Text
  306. 'Insert path name
  307. procInsPath
  308. 'If not in LZH mode then hide frmgetfile
  309. If LZHstatus = 0 Then
  310.  frmGetFile.Hide
  311. Else              'End LZH filename mode
  312.  LZHstatus = 2
  313.  frmGetFile.Caption = "Select a file" 'Change form name
  314.  txtLZHname.Text = txtFileName.Text   'Set LZH file name
  315.  LZHname = frmGetFile.Tag
  316.  txtFileName.Text = ""                'Clear file name
  317. End If
  318. End Sub
  319. Sub dirDirectory_Change ()
  320. 'Change the path of the file list box
  321. filFiles.Path = dirDirectory.Path
  322. 'Update lblDirName
  323. lblDirName.Caption = dirDirectory.Path
  324. End Sub
  325. Sub dirDirectory_KeyPress (KeyAscii As Integer)
  326. If KeyAscii = 13 Then
  327.  'Change path
  328.  dirDirectory.Path = dirDirectory.List(dirDirectory.ListIndex)
  329. End If
  330. End Sub
  331. Sub drvDrive_Change ()
  332. 'Set Error trap
  333. On Error GoTo DriveError
  334. 'Change the path of the directory list box to new drive
  335. dirDirectory.Path = drvDrive.Drive
  336. Exit Sub
  337. 'Error routine
  338. DriveError:
  339. 'Restore to the original drive
  340. MsgBox "Drive error!", 48, "Error"
  341. drvDrive.Drive = dirDirectory.Path
  342. Exit Sub
  343. End Sub
  344. Sub filFiles_Click ()
  345. 'Update the txtFileName text box
  346. txtFileName = filFiles.FileName
  347. End Sub
  348. 'Copyright 1995  by Hitoshi Ozawa
  349. Sub filFiles_DblClick ()
  350. 'If it is a LHA file, open frmlha
  351. If Right$(filFiles.FileName, 3) = "lzh" Then
  352.  'Save file name in fname variable
  353.  workfile.lopen = filFiles.FileName
  354.  procInsPath
  355.  frmlha.Show 1
  356.  If frmlha.Tag = "" Then
  357.    workfile.lopen = ""
  358.    Exit Sub
  359.  End If
  360.  filFiles.FileName = frmlha.Tag
  361.  Exit Sub
  362. End If
  363. 'Update the txtfilename text box with selected file name
  364. txtFileName = filFiles.FileName
  365. 'execute the cmdOK_Click()
  366. cmdOK_Click
  367. End Sub
  368. Sub filFiles_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  369. 'Change drag icon
  370. filFiles.DragIcon = picFile1
  371. 'Enable drag
  372. filFiles.Drag
  373. End Sub
  374. Sub Form_Load ()
  375. 'Update the Directory lblDir Name with the path of directory list box
  376. lblDirName.Caption = dirDirectory.Path
  377. 'Display closed LZH cabinet
  378. picLZH.Picture = picLZHclose.Picture
  379. LZHstatus = 0
  380. End Sub
  381. Sub picLZH_Click ()
  382. If LZHstatus = 0 Then
  383.   picLZH = picLZHopen      'If close the open file
  384.   LZHstatus = 1
  385.   frmGetFile.Caption = "Select LZH file name"
  386.   picLZH = picLZHclose      'If open the close file
  387.   LZHstatus = 0
  388.   frmGetFile.Caption = "Select a file"
  389.   txtLZHname.Text = ""      'Clear LHA file name
  390.   txtFileName.Text = ""     'Clear file name
  391. End If
  392. End Sub
  393. Sub picLZH_DragDrop (Source As Control, X As Single, Y As Single)
  394. Dim retcode As Integer
  395. Dim curpath As String
  396. Dim cnt
  397. 'If file is not selected do nothing
  398. If txtFileName = "" Then
  399.  Exit Sub
  400. End If
  401. If LZHstatus = 0 Then
  402.  If LCase$(Right$(txtFileName.Text, 3)) = "lzh" Then
  403.    picLZH_Click
  404.   Else
  405.    Exit Sub              'Exit if not in LZH mode
  406.   End If
  407. End If
  408. If LZHstatus = 1 Then
  409.   LZHstatus = 2
  410.   txtLZHname.Text = txtFileName.Text
  411.   frmGetFile.Caption = "Select a file" 'Change form name
  412.   procInsPath                          'Insert a path
  413.   LZHname = frmGetFile.Tag        'Set LZH file name
  414.   txtFileName.Text = ""                'Clear file name
  415.   Exit Sub
  416. End If
  417. 'If LZH file name is not entered, prompt a file name
  418. If txtLZHname = "" Then
  419.   MsgBox ("Select a LZH file!")
  420.   Exit Sub
  421. End If
  422. 'Reset buffer size
  423. buffer = Space(szbuff)
  424. 'Attach path name
  425. procInsPath
  426. 'Save current path
  427. curpath = CurDir
  428. ChDrive Mid$(frmGetFile.Tag, 1, 2)
  429. ChDir frmGetFile.filFiles.Path
  430. 'Create LHA command
  431. cmd = "a " & LZHname & " " & frmGetFile.Tag
  432. 'Perform LHA operation
  433. retcode = lha(cmd, buffer, szbuff)
  434. 'Check for error
  435. If retcode <> 0 Then
  436.  MsgBox ("LHA file add error: " & retcode)
  437.  Exit Sub
  438. End If
  439. 'Return to original drive
  440. ChDrive Mid$(curpath, 1, 2)
  441. 'Return to original path
  442. ChDir curpath
  443. 'refresh getfile file box
  444. frmGetFile.filFiles.Refresh
  445. End Sub
  446. Sub picLZH_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  447. If LZHstatus = 1 Then
  448.  Select Case State
  449.   Case 0
  450.     'change icon to entry
  451.       picLZH.Picture = picLZHenter.Picture
  452.   Case 1
  453.     'change icon back to open
  454.      picLZH.Picture = picLZHopen.Picture
  455.  End Select
  456. End If
  457. End Sub
  458. Sub txtFileName_KeyPress (KeyAscii As Integer)
  459. If KeyAscii = 13 Then
  460.   If (InStr(txtFileName.Text, "*") <> 0) Or (InStr(txtFileName.Text, "?") <> 0) Then
  461.     'set the pattern of the filfiles to the select pattern
  462.     filFiles.Pattern = txtFileName.Text
  463.   End If
  464. End If
  465. End Sub
  466.