VERSION 5.00 Object = "{25C953A7-5464-11D1-A714-00AA0044064C}#1.0#0"; "MSCEFILE.DLL" Object = "{D863DA15-8C5B-11D1-86C0-00AA003EE054}#1.0#0"; "mscetreeview.dll" Begin VB.Form frmOpen Appearance = 0 'Flat AutoRedraw = -1 'True BackColor = &H80000005& Caption = "Open" ClientHeight = 3510 ClientLeft = 60 ClientTop = 840 ClientWidth = 3480 ControlBox = -1 'True ForeColor = &H80000008& LockControls = -1 'True ScaleHeight = 3510 ScaleWidth = 3480 Begin FILECTLCtl.FileSystem ceFileSystem Left = 1740 Top = 180 _cx = 2200 _cy = 1400 End Begin MSCETREEVIEWLibCtl.TreeViewCtl tvwDirectories Height = 1275 Left = 30 TabIndex = 0 Top = 0 Width = 3435 _cx = 6059 _cy = 2249 FontBold = 0 'False FontItalic = 0 'False FontName = "Tahoma" FontSize = 8 FontStrikethrough= 0 'False FontUnderline = 0 'False HideSelection = -1 'True Indentation = 0 LabelEdit = 1 LineStyle = 1 PathSeparator = "/" Style = 6 Enabled = -1 'True End Begin VBCE.CommandButton cmdSaveAs Height = 255 Left = 120 TabIndex = 9 Top = 3240 Visible = 0 'False Width = 615 _cx = 1085 _cy = 450 BackColor = 12632256 Caption = "SaveAs" Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Style = 0 End Begin VBCE.TextBox txtFilename Height = 255 Left = 1200 TabIndex = 8 Top = 2760 Width = 2175 _cx = 3836 _cy = 450 BackColor = -2147483643 BorderStyle = 1 Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483640 Text = "" Alignment = 0 HideSelection = -1 'True Locked = 0 'False MaxLength = 0 MultiLine = -1 'True PasswordChar = "" ScrollBars = 0 End Begin VBCE.Label lblFilesOfType Height = 210 Left = 120 TabIndex = 7 Top = 3000 Width = 975 _cx = 1720 _cy = 370 AutoSize = 0 'False BackColor = -2147483643 BackStyle = 0 BorderStyle = 0 Caption = "Files of type:" Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483640 Alignment = 0 UseMnemonic = -1 'True WordWrap = 0 'False End Begin VBCE.CommandButton cmdCancel Height = 255 Left = 2760 TabIndex = 6 Top = 3240 Width = 615 _cx = 1085 _cy = 450 BackColor = 12632256 Caption = "Cancel" Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Style = 0 End Begin VBCE.Label lblFilename Height = 210 Left = 120 TabIndex = 5 Top = 2760 Width = 855 _cx = 1508 _cy = 370 AutoSize = 0 'False BackColor = -2147483643 BackStyle = 0 BorderStyle = 0 Caption = "File name:" Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483640 Alignment = 0 UseMnemonic = -1 'True WordWrap = 0 'False End Begin VBCE.CommandButton cmdDelete Height = 255 Left = 120 TabIndex = 4 Top = 3240 Visible = 0 'False Width = 615 _cx = 1085 _cy = 450 BackColor = 12632256 Caption = "Delete" Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Style = 0 End Begin VBCE.ComboBox cboFileFilter Height = 300 Left = 1200 TabIndex = 3 Top = 3060 Width = 855 List = "frmOpen.frx":0000 ItemData = "frmOpen.frx":0028 _cx = 1508 _cy = 529 BackColor = -2147483643 Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483640 Text = "" IntegralHeight = -1 'True Locked = 0 'False Sorted = 0 'False Style = 0 End Begin VBCE.CommandButton cmdOpen Height = 255 Left = 2160 TabIndex = 2 Top = 3240 Width = 495 _cx = 873 _cy = 450 BackColor = 12632256 Caption = "Open" Enabled = 0 'False BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Style = 0 End Begin VBCE.ListBox lstFiles Height = 1395 Left = 30 TabIndex = 1 Top = 1320 Width = 3435 List = "frmOpen.frx":0050 ItemData = "frmOpen.frx":0078 _cx = 6059 _cy = 2461 BackColor = -2147483643 Enabled = -1 'True BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483640 Columns = 0 IntegralHeight = -1 'True MultiSelect = 0 Sorted = 0 'False End End Attribute VB_Name = "frmOpen" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Public OpenFilePath As String Public SaveFilePath As String Public Done As Boolean 'Private Function OpenFileDlg(strFilter As String, strDefaultExt As String) As String ' frmOpen.Done = False ' frmOpen.OpenFilePath = "" ' frmOpen.ClearFileFilters ' frmOpen.SetFileFilter "*.*", "*.*" ' frmOpen.SetFileFilter strFilter, strDefaultExt ' frmOpen.Hide ' frmOpen.Show vbModal ' Do ' CEDoEvents ' Loop Until frmOpen.Done ' OpenFileDlg = frmOpen.OpenFilePath 'End Function ' 'Private Sub cmdOpenDialog_Click() ' Dim strFilename As String ' strFilename = OpenFileDlg("*.mca", "*.mca") ' If (Len(strFilename) > 0) Then ' Text1.Text = strFilename ' Else ' Text1.Text = "File not found." ' End If 'End Sub Private Sub cboFileFilter_Change() UpdateDirectories cmdOpen.Enabled = False End Sub Private Sub cboFileFilter_Click() Dim strFilter As String strFilter = cboFileFilter.List(cboFileFilter.ListIndex) ReadDirectory GetPath(), ceFileSystem, tvwDirectories, tvwDirectories.SelectedItem, lstFiles, strFilter cmdOpen.Enabled = False End Sub Private Sub cmdCancel_Click() Form_OKClick End Sub Private Sub cmdDelete_Click() Dim strPath As String Dim strFilename As String On Error Resume Next If lstFiles.ListIndex < 0 Then Exit Sub strFilename = lstFiles.List(lstFiles.ListIndex) strPath = GetPath() & "\" & strFilename If MsgBox("Delete file?: " & vbCrLf & strFilename, vbYesNo, "Delete File?") = vbNo Then Exit Sub ceFileSystem.Kill strPath If Err.Number <> 0 Then MsgBox "Unable to delete file. It may be in use or protected", vbExclamation, "Error" End If UpdateDirectories End Sub Private Sub cmdOpen_Click() Dim strPath As String Dim strPathFinal As String Dim strContents As String Dim strFilename As String Dim idxChar As Long strPath = GetPath() strFilename = lstFiles.List(lstFiles.ListIndex) strPath = strPath & "\" & strFilename strPathFinal = "" For idxChar = 1 To Len(strPath) If (Mid(strPath, idxChar, 1) = "/") Then strPathFinal = strPathFinal & "\" Else strPathFinal = strPathFinal & Mid(strPath, idxChar, 1) End If Next OpenFilePath = strPathFinal Form_OKClick End Sub Private Sub cmdSaveAs_Click() Dim strPath As String Dim strPathFinal As String Dim strContents As String Dim strFilename As String Dim idxChar As Long strPath = GetPath() strFilename = txtFilename.Text strPath = strPath & "\" & strFilename strPathFinal = "" For idxChar = 1 To Len(strPath) If (Mid(strPath, idxChar, 1) = "/") Then strPathFinal = strPathFinal & "\" Else strPathFinal = strPathFinal & Mid(strPath, idxChar, 1) End If Next SaveFilePath = strPathFinal Form_OKClick End Sub Private Sub Form_Load() Dim nodRoot As MSCETREEVIEWLibCtl.Node tvwDirectories.Nodes.Clear Set nodRoot = tvwDirectories.Nodes.Add(, , "Root", "My Device") nodRoot.Selected = True cboFileFilter.AddItem "*.*" cboFileFilter.Text = "*.*" nodRoot.Expanded = True Set nodRoot = Nothing End Sub Private Sub Form_OKClick() frmOpen.Hide Done = True End Sub Private Sub lstFiles_Click() Dim strPath As String If lstFiles.ListIndex >= 0 Then cmdOpen.Enabled = True strPath = lstFiles.List(lstFiles.ListIndex) txtFilename.Text = strPath Else cmdOpen.Enabled = False End If End Sub Private Sub tvwDirectories_NodeClick(ByVal Index As Long) UpdateDirectories cmdOpen.Enabled = False End Sub Private Function GetPath() As String GetPath = Replace(tvwDirectories.SelectedItem.FullPath, "My Device", "") End Function Private Sub UpdateDirectories() ReadDirectory GetPath(), ceFileSystem, tvwDirectories, tvwDirectories.SelectedItem, lstFiles, cboFileFilter.Text End Sub Public Sub ReadDirectory(Path As String, _ fsFileSystem As FILECTLCtl.FileSystem, _ tvwTreeView As MSCETREEVIEWLibCtl.TreeViewCtl, _ nodParentNode As MSCETREEVIEWLibCtl.Node, _ lstListBox As ListBox, _ strFilter As String) Dim strDir As String Dim strFile As String On Error Resume Next If Right(Path, 1) <> "\" Then Path = Path & "\" strDir = fsFileSystem.Dir(Path & "*", fsAttrDirectory) Do While strDir <> "" tvwTreeView.Nodes.Add nodParentNode.Key, tvwChild, strDir, strDir If Err.Number = 35602 Then 'do nothing ElseIf Err.Number <> 0 Then MsgBox Err.Description, vbExclamation, "Error adding node!" End If strDir = fsFileSystem.Dir Loop lstListBox.Clear strFile = fsFileSystem.Dir(Path & strFilter, fsAttrNormal) Do While strFile <> "" lstListBox.AddItem strFile strFile = fsFileSystem.Dir Loop End Sub Public Sub ClearFileFilters() cboFileFilter.Clear End Sub Public Sub SetFileFilter(strFilter As String, strDefault As String) If (Len(strFilter) > 0) Then cboFileFilter.AddItem strFilter If (Len(strDefault) > 0) Then cboFileFilter.Text = strDefault End Sub Public Sub SetDialogType(isSaveAs As Boolean) If (isSaveAs) Then frmOpen.Caption = "Save As" cmdOpen.Visible = False cmdSaveAs.Visible = True Else frmOpen.Caption = "Open" cmdOpen.Visible = True cmdSaveAs.Visible = False End If End Sub