VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmModelDir 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "IC Profile Directory"
   ClientHeight    =   4245
   ClientLeft      =   2820
   ClientTop       =   3465
   ClientWidth     =   7110
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   HelpContextID   =   500
   Icon            =   "frmModelDir.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4245
   ScaleWidth      =   7110
   StartUpPosition =   1  'CenterOwner
   Begin MSComctlLib.ProgressBar pbScanProgress 
      Height          =   285
      Left            =   75
      TabIndex        =   5
      Top             =   3870
      Width           =   2940
      _ExtentX        =   5186
      _ExtentY        =   503
      _Version        =   393216
      Appearance      =   0
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "&Cancel"
      Height          =   330
      Left            =   5865
      TabIndex        =   4
      Top             =   3840
      Width           =   1155
   End
   Begin VB.CommandButton cmdDoIt 
      Caption         =   "&Load"
      Height          =   330
      HelpContextID   =   500
      Left            =   4560
      TabIndex        =   3
      Top             =   3840
      Width           =   1155
   End
   Begin MSComctlLib.ListView lvFiles 
      Height          =   3615
      HelpContextID   =   500
      Left            =   3105
      TabIndex        =   2
      Top             =   90
      Width           =   3930
      _ExtentX        =   6932
      _ExtentY        =   6376
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      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
      NumItems        =   0
   End
   Begin VB.DirListBox Dir1 
      Height          =   3240
      HelpContextID   =   500
      Left            =   105
      TabIndex        =   1
      Top             =   450
      Width           =   2910
   End
   Begin VB.DriveListBox Drive1 
      Height          =   315
      HelpContextID   =   500
      Left            =   105
      TabIndex        =   0
      Top             =   105
      Width           =   2910
   End
   Begin VB.FileListBox File1 
      Height          =   480
      Left            =   3255
      Pattern         =   "*.mod"
      TabIndex        =   6
      Top             =   3225
      Visible         =   0   'False
      Width           =   3150
   End
End
Attribute VB_Name = "frmModelDir"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public pbCancel                                 As Boolean
Public psModelFileName                          As String

Private mbLoading                               As Boolean

Private Const Module_Name                       As String = "frmModelDir"
Public Property Let Mode(nMode As Integer)
' Is this form working as
' 0 - Browse and select IC model
' 1 - Just select a directory location

    Select Case nMode
    Case 0
        ' Do nothing
        
    Case 1
        ' Reconfigure the form and buttons
        pbScanProgress.Visible = False
        cmdDoIt.Left = 250
        cmdDoIt.Caption = "&OK"
        cmdCancel.Left = 1700
        Me.Width = 3180
        
    Case Else
        MsgBox "Unrecognised frmModelDir Mode:" & Format$(nMode)
    
    End Select
    
End Property

Private Sub cmdCancel_Click()
    
    pbCancel = True
    Me.Hide
    
End Sub

Private Sub cmdDoIt_Click()

    ' Save settings
    SaveSetting App.Title, "Defaults", "Paths0", Dir1.Path
    gsPaths(0) = Dir1.Path
    
    pbCancel = False
    Me.Hide
    
End Sub


Private Sub Dir1_Change()

    If mbLoading = False Then
        File1.Path = Dir1.Path
    End If
    
End Sub

Private Sub Drive1_Change()

    Dir1.Path = Drive1.Drive
    
End Sub

Private Sub File1_PathChange()

    Dim F                               As Integer
    Dim itm                             As ListItem
    Dim sFileName                       As String

    Const PROC_NAME                     As String = "File1_PathChange"
    
    On Error GoTo ErrorHandler

    If File1.ListCount > 0 Then
        ' There are some files of interest here
        
        pbScanProgress.Max = File1.ListCount
        pbScanProgress.Visible = False
        pbScanProgress.Value = 0
        Screen.MousePointer = 11
        DoEvents
        
        With lvFiles
            .Visible = False
            .ColumnHeaders.Clear
            .ListItems.Clear
            .ColumnHeaders.Add , "H1", "File Name", 1000
            .ColumnHeaders.Add , "H2", "Description", .Width
            If File1.ListCount > 10 Then
                pbScanProgress.Visible = True
            End If

            For F = 0 To File1.ListCount - 1
                pbScanProgress.Value = F + 1
                DoEvents
                
                Set itm = .ListItems.Add
                
                sFileName = File1.List(F)
                itm.Text = Left$(sFileName, Len(sFileName) - 4)
                
                ' Recover the file description
                itm.SubItems(1) = GetFileDescription(Dir1.Path & "\" & File1.List(F))
            Next F
        
            .Visible = True
        End With
            
    Else
        ' Nothing of interest
        lvFiles.ListItems.Clear
        
    End If
    
    pbScanProgress.Visible = False
    Screen.MousePointer = 0
    
    Exit Sub
    
ErrorHandler:
    ErrorRoutine Module_Name, PROC_NAME, Err
End Sub


Private Sub Form_Load()

    mbLoading = True
    
    On Error Resume Next
    
    Drive1.Drive = gsPaths(0)
    Dir1.Path = gsPaths(0)
    File1.Path = gsPaths(0)

    mbLoading = False
    
End Sub



Private Sub lvFiles_Click()

    psModelFileName = File1.Path & "\" & lvFiles.SelectedItem.Text & ".mod"
    
End Sub


Private Sub lvFiles_DblClick()

    Call cmdDoIt_Click
    
End Sub



Private Sub lvFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    lvFiles.SetFocus
    
End Sub


