VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form frmNew 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "What Do You Want To Do?"
   ClientHeight    =   3345
   ClientLeft      =   2640
   ClientTop       =   1905
   ClientWidth     =   5685
   Icon            =   "frmNew.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3345
   ScaleWidth      =   5685
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   WindowState     =   1  'Minimized
   Begin VB.Frame Frame2 
      Height          =   1900
      Left            =   120
      TabIndex        =   6
      Top             =   770
      Width           =   5415
      Begin VB.PictureBox Picture1 
         Appearance      =   0  'Flat
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   1575
         Left            =   120
         ScaleHeight     =   1575
         ScaleWidth      =   5175
         TabIndex        =   7
         Top             =   240
         Width           =   5175
         Begin VB.OptionButton optOpenFile 
            Caption         =   "Open an existing toolbar project"
            Height          =   255
            Left            =   480
            TabIndex        =   12
            Top             =   0
            Width           =   2655
         End
         Begin VB.CommandButton cmdOpenExistingFile 
            Caption         =   "..."
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   204
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   285
            Left            =   4800
            TabIndex        =   11
            Top             =   1200
            Width           =   375
         End
         Begin VB.TextBox txtExistingFile 
            Enabled         =   0   'False
            Height          =   285
            Left            =   0
            Locked          =   -1  'True
            TabIndex        =   10
            Top             =   1200
            Width           =   4695
         End
         Begin VB.ListBox lstHistory 
            Enabled         =   0   'False
            Height          =   645
            ItemData        =   "frmNew.frx":08CA
            Left            =   0
            List            =   "frmNew.frx":08CC
            TabIndex        =   9
            Top             =   360
            Width           =   4695
         End
         Begin VB.PictureBox Picture4 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BorderStyle     =   0  'None
            ForeColor       =   &H80000008&
            Height          =   240
            Left            =   0
            Picture         =   "frmNew.frx":08CE
            ScaleHeight     =   240
            ScaleWidth      =   240
            TabIndex        =   8
            Top             =   0
            Width           =   240
         End
      End
   End
   Begin VB.Frame Frame1 
      Height          =   615
      Left            =   120
      TabIndex        =   2
      Top             =   80
      Width           =   5415
      Begin VB.PictureBox Picture2 
         Appearance      =   0  'Flat
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   300
         Left            =   120
         ScaleHeight     =   300
         ScaleWidth      =   3375
         TabIndex        =   3
         Top             =   220
         Width           =   3375
         Begin VB.OptionButton optNewFile 
            Caption         =   "Create a new toolbar project"
            Height          =   255
            Left            =   480
            TabIndex        =   5
            Top             =   0
            Value           =   -1  'True
            Width           =   2775
         End
         Begin VB.PictureBox Picture3 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BorderStyle     =   0  'None
            ForeColor       =   &H80000008&
            Height          =   240
            Left            =   0
            Picture         =   "frmNew.frx":0E58
            ScaleHeight     =   240
            ScaleWidth      =   240
            TabIndex        =   4
            Top             =   0
            Width           =   240
         End
      End
   End
   Begin MSComDlg.CommonDialog dlgOpen 
      Left            =   240
      Top             =   2640
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DefaultExt      =   "tbs"
      DialogTitle     =   "Please select toolbar project file to open"
      Filter          =   "Toolbar Software Files|*.tbs"
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "&Exit"
      Height          =   375
      Left            =   4200
      TabIndex        =   1
      Top             =   2850
      Width           =   1335
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      Default         =   -1  'True
      Height          =   375
      Left            =   2760
      TabIndex        =   0
      Top             =   2850
      Width           =   1335
   End
End
Attribute VB_Name = "frmNew"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public strFileName As String
Public bOpenExisting As Boolean ' if true, then open file name "strFileName" else create new project
Public bExit As Boolean

Private fileHist As New CFileHistory

Private Sub cmdExit_Click()
    bExit = True
    Hide
End Sub

Private Sub cmdOk_Click()
    If optNewFile.Value = True Then
        bExit = False
        bOpenExisting = False
        Hide
        Exit Sub
    Else
        If Not FileExists(txtExistingFile.Text) Then
            MsgBox "File not exist or this file is zero-length!", vbExclamation
            Exit Sub
        End If
        
        strFileName = txtExistingFile.Text
        addItem (txtExistingFile.Text)
        bExit = False
        bOpenExisting = True
        Hide
    End If
End Sub

Private Sub cmdOpenExistingFile_Click()
        
    On Error GoTo ErrHandler
    
    Dim strFileName As String
    ' Get file name
    dlgOpen.CancelError = True
    dlgOpen.ShowOpen
    
    strFileName = dlgOpen.FileName
      
    addItem strFileName
    txtExistingFile.Text = strFileName
    Exit Sub
    
ErrHandler:
    If Err.Number <> cdlCancel Then
        MsgBox Err.Description, vbExclamation
    End If
End Sub

Private Sub addItem(str As String)
  If Not fileHist.OnList(str) Then
     fileHist.AddNewItem str
     lstHistory.addItem str, 0
  Else
     fileHist.MoveItemToTop str
     
     Dim i As Integer
     For i = 0 To lstHistory.ListCount - 1
        If lstHistory.List(i) = str Then Exit For
     Next i
     If i < lstHistory.ListCount Then
        lstHistory.RemoveItem i
        lstHistory.addItem str, 0
     End If
  End If
End Sub


Private Sub Form_Load()

    SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
    WindowState = vbNormal

    Dim cItems As Collection
    Dim i As Long
    lstHistory.Clear
    Set cItems = fileHist.Items
    For i = 1 To cItems.Count
        lstHistory.addItem cItems(i)
    Next
   
    bExit = True
    
    If fileHist.Items.Count > 0 Then
        txtExistingFile.Text = fileHist.Items(1)
        optOpenFile_Click
    End If
   
End Sub

Private Sub lstHistory_Click()
    txtExistingFile.Text = lstHistory.List(lstHistory.ListIndex)
End Sub

Private Sub optNewFile_Click()
    optNewFile.Value = True
    optOpenFile.Value = False
   
    lstHistory.Enabled = False
    txtExistingFile.Enabled = False
    cmdOpenExistingFile.Enabled = False
End Sub

Private Sub optOpenFile_Click()
    optNewFile.Value = False
    optOpenFile.Value = True
   
    lstHistory.Enabled = True
    txtExistingFile.Enabled = True
    cmdOpenExistingFile.Enabled = True
End Sub

