vbAccelerator - Contents of code file: frmNew.frm

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmNew 
   Caption         =   "Open"
   ClientHeight    =   5100
   ClientLeft      =   2328
   ClientTop       =   1692
   ClientWidth     =   6492
   ClipControls    =   0   'False
   Icon            =   "frmNew.frx":0000
   LinkTopic       =   "Form2"
   ScaleHeight     =   5100
   ScaleWidth      =   6492
   Begin VB.Timer tmrUnload 
      Enabled         =   0   'False
      Interval        =   50
      Left            =   4500
      Top             =   4740
   End
   Begin VB.PictureBox m_Controls 
      BorderStyle     =   0  'None
      Height          =   5010
      Left            =   60
      ScaleHeight     =   5016
      ScaleWidth      =   6372
      TabIndex        =   0
      Top             =   60
      Visible         =   0   'False
      Width           =   6375
      Begin ComctlLib.ListView lvwNew 
         Height          =   2520
         Left            =   120
         TabIndex        =   7
         Top             =   1080
         Width           =   6156
         _ExtentX        =   10859
         _ExtentY        =   4445
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         _Version        =   327682
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.4
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   0
      End
      Begin ComctlLib.ListView lvwRecent 
         Height          =   2520
         Left            =   120
         TabIndex        =   6
         Top             =   960
         Visible         =   0   'False
         Width           =   6156
         _ExtentX        =   10859
         _ExtentY        =   4445
         View            =   3
         Arrange         =   2
         LabelEdit       =   1
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         _Version        =   327682
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.4
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   3
         BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "File"
            Object.Width           =   2540
         EndProperty
         BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   1
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Folder"
            Object.Width           =   2540
         EndProperty
         BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   2
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Date"
            Object.Width           =   2540
         EndProperty
      End
      Begin VB.PictureBox imgSplash 
         Enabled         =   0   'False
         Height          =   555
         Left            =   0
         Picture         =   "frmNew.frx":014A
         ScaleHeight     =   504
         ScaleWidth      =   6324
         TabIndex        =   4
         TabStop         =   0   'False
         Top             =   0
         Width           =   6375
         Begin VB.Image imgVBAccelerator 
            Height          =   264
            Left            =   120
            Picture         =   "frmNew.frx":0B93
            Top             =   120
            Width           =   1020
         End
         Begin VB.Label lblSplash 
            BackStyle       =   0  'Transparent
            Caption         =   "Hooked File Open Dialog Demo"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   14.4
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   372
            Left            =   1320
            TabIndex        =   5
            Top             =   60
            Width           =   4212
         End
      End
      Begin VB.CheckBox chkDont 
         Caption         =   "Don't show this dialog in the f&uture"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.4
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   60
         TabIndex        =   3
         Top             =   4740
         Width           =   5055
      End
      Begin VB.CommandButton cmdNewOpen 
         Caption         =   "&Open"
         Default         =   -1  'True
         Height          =   345
         Left            =   5040
         TabIndex        =   2
         Top             =   3660
         Width           =   1125
      End
      Begin VB.CommandButton CmdNewCancel 
         Caption         =   "&Cancel"
         Height          =   345
         Left            =   5030
         TabIndex        =   1
         Top             =   4065
         Width           =   1125
      End
      Begin ComctlLib.TabStrip tabMain 
         Height          =   3990
         Left            =   0
         TabIndex        =   8
         Top             =   600
         Width           =   6375
         _ExtentX        =   11240
         _ExtentY        =   7049
         _Version        =   327682
         BeginProperty Tabs {0713E432-850A-101B-AFC0-4210102A8DA7} 
            NumTabs         =   3
            BeginProperty Tab1 {0713F341-850A-101B-AFC0-4210102A8DA7} 
               Caption         =   "New"
               Object.Tag             =   ""
               ImageVarType    =   2
            EndProperty
            BeginProperty Tab2 {0713F341-850A-101B-AFC0-4210102A8DA7} 
               Caption         =   "Existing"
               Object.Tag             =   ""
               ImageVarType    =   2
            EndProperty
            BeginProperty Tab3 {0713F341-850A-101B-AFC0-4210102A8DA7} 
               Caption         =   "Recent"
               Object.Tag             =   ""
               ImageVarType    =   2
            EndProperty
         EndProperty
      End
   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 WithEvents cD As cCommonDialog
Attribute cD.VB_VarHelpID = -1


Private ShiftDlgX As Long
Private ShiftDlgY As Long

'Holds Dlg Toolbarhwnd
Private Tbhwnd  As Long
'Tmp String for when we change tabs and then return to existing tab
Private TmpFileTxt      As String * 256
'Tab to clean up before showing new tab
Private LastTabFocus    As String

Private m_hwnd As Long
Private m_hDlg As Long
Private m_bCancel As Boolean
Private m_sFileName As String

Private m_bShowNew As Boolean
Private m_bIsNew As Boolean

Private m_ilsNew As ImageList
Private m_ilsExist As ImageList
Private m_sNewName() As String
Private m_vNewIcon() As Variant
Private m_iNewCount As Long
Private m_sExistName() As String
Private m_sExistFolder() As String
Private m_dExistDate() As Date
Private m_vExistIcon() As Variant
Private m_iExistCOunt As Long

Public Function SetBackwardFocus() As Long
Dim CurHnd As Long
Dim NewHnd As Long

   CurHnd = GetFocusAPI()
        
   If tabMain.SelectedItem = "New" Then
  
      Select Case CurHnd
      Case tabMain.hWnd
         SetFocusAPI CmdNewCancel.hWnd
      Case lvwNew.hWnd
         SetFocusAPI tabMain.hWnd
      Case cmdNewOpen.hWnd
         SetFocusAPI lvwNew.hWnd
      Case CmdNewCancel.hWnd
          SetFocusAPI cmdNewOpen.hWnd
      Case Else
         SetFocusAPI tabMain.hWnd
      End Select
  
      NewHnd = 1
  
   ElseIf tabMain.SelectedItem = "Recent" Then
      Select Case CurHnd
      Case tabMain.hWnd
         Exit Function
      Case GetDlgItem(m_hwnd, fdlgIDCANCEL)
         Exit Function
      Case GetDlgItem(m_hwnd, fdlgIDOK)
         SetFocusAPI lvwRecent.hWnd
      Case lvwRecent.hWnd
         SetFocusAPI tabMain.hWnd
      Case Else
         SetFocusAPI tabMain.hWnd
      End Select
      
      NewHnd = 1
   Else
 
   End If

   If NewHnd <> 0 Then
      SetBackwardFocus = 1
   Else
      SetBackwardFocus = 0
   End If

End Function

Private Sub SetControlPos(ByVal hd As Long, ByVal SFlags As Long, Optional
 ByVal lID As Long = -1)
Dim tdr As RECT
Dim wLp As POINTAPI
Dim lShiftX As Long
Dim lShiftY As Long
 
   GetWindowRect hd, tdr
   ScreenToClient m_hwnd, wLp
      
   lShiftX = tabMain.ClientLeft \ Screen.TwipsPerPixelX
   lShiftY = tabMain.ClientTop \ Screen.TwipsPerPixelY + 2
   wLp.X = wLp.X + tdr.Left + lShiftX
   wLp.Y = wLp.Y + tdr.Top + lShiftY
   
   SetWindowPos hd, 0, wLp.X, wLp.Y, 0, 0, SFlags
   
   If lID = fdlgIDCANCEL Then
      ' Position VB Cancel:
      CmdNewCancel.Move wLp.X * Screen.TwipsPerPixelX - m_Controls.Left, wLp.Y
       * Screen.TwipsPerPixelY - m_Controls.Top, (tdr.Right - tdr.Left) *
       Screen.TwipsPerPixelX, (tdr.Bottom - tdr.Top) * Screen.TwipsPerPixelY
   ElseIf lID = fdlgIDOK Then
      ' Position VB OK:
      cmdNewOpen.Move wLp.X * Screen.TwipsPerPixelX - m_Controls.Left, wLp.Y *
       Screen.TwipsPerPixelY - m_Controls.Top, (tdr.Right - tdr.Left) *
       Screen.TwipsPerPixelX, (tdr.Bottom - tdr.Top) * Screen.TwipsPerPixelY
      ' Position ListViews:
      lvwRecent.Move lvwRecent.Left, lvwRecent.Top, _
         cmdNewOpen.Left + cmdNewOpen.Width - lvwRecent.Left, _
         cmdNewOpen.Top - lvwRecent.Top - 4 * Screen.TwipsPerPixelY
      lvwNew.Move lvwRecent.Left, lvwRecent.Top, lvwRecent.Width,
       lvwRecent.Height
   End If
    
End Sub

Public Function SetForwardFocus() As Long
Dim CurHnd As Long
Dim NewHnd As Long
    
   CurHnd = GetFocusAPI()
 
   If tabMain.SelectedItem = "New" Then
  
      Select Case CurHnd
      Case tabMain.hWnd
         SetFocusAPI cmdNewOpen.hWnd
         If lvwNew.ListItems.Count > 0 Then
            SetFocusAPI lvwNew.hWnd
         End If
      Case lvwNew.hWnd
         SetFocusAPI cmdNewOpen.hWnd
      Case cmdNewOpen.hWnd
         SetFocusAPI CmdNewCancel.hWnd
      Case CmdNewCancel.hWnd
         SetFocusAPI tabMain.hWnd
      Case Else
         SetFocusAPI tabMain.hWnd
      End Select
      
      NewHnd = 1
  
   ElseIf tabMain.SelectedItem = "Recent" Then
  
      Select Case CurHnd
      Case tabMain.hWnd
         If lvwRecent.ListItems.Count > 0 Then
            SetFocusAPI lvwRecent.hWnd
         Else
            SetFocusAPI GetDlgItem(m_hwnd, fdlgIDCANCEL)
            Exit Function
         End If
      Case lvwRecent.hWnd
         If lvwRecent.ListItems.Count > 0 Then
            SetFocusAPI GetDlgItem(m_hwnd, fdlgIDOK)
         Else
            SetFocusAPI GetDlgItem(m_hwnd, fdlgIDCANCEL)
            Exit Function
         End If
      Case GetDlgItem(m_hwnd, fdlgIDOK)
         Exit Function
      Case GetDlgItem(m_hwnd, fdlgIDCANCEL)
         Exit Function
      Case Else
         SetFocusAPI tabMain.hWnd
      End Select
  
      NewHnd = 1
  
   Else
 
   End If

   If NewHnd <> 0 Then
      SetForwardFocus = 1
   Else
      SetForwardFocus = 0
   End If

End Function


Private Sub cD_DialogOK(bCancel As Boolean)
   bCancel = True
   m_bCancel = False
   m_sFileName = GetCDlgFileName(m_hDlg)
   tmrUnload.Enabled = True
End Sub

Private Sub cD_FolderChange(ByVal hDlg As Long)
Static DoOnce As Boolean
Dim hd As Long
 
   If Not DoOnce Then
      'We do this because the file listvw was not_
      'created till after dialog intialize
 
      If m_bShowNew Then
         hd = GetDlgItem(m_hwnd, fdlgLVLstFiles)
         SetControlPos hd, SWP_MOVEHIDE Or SWP_NOMOVE Or SWP_NOZORDER
      Else
         SetFocusAPI m_Controls.hWnd
      End If
      
      m_Controls.Visible = True
      m_Controls.ZOrder 1
      DoOnce = True
   End If
End Sub


Private Sub cD_InitDialog(ByVal hDlg As Long)
Dim hd As Long
Dim tR As RECT, tTR As RECT
Dim lW As Long, lH As Long
    
   m_hDlg = hDlg
   ' For Open/Save dialog we need the parent of the supplied dialog handle:
   m_hwnd = GetParent(hDlg)
   GetWindowRect m_hwnd, tTR
        
   If m_bShowNew Then
      
      '// Cancel Button
      hd = GetDlgItem(m_hwnd, fdlgIDCANCEL)
      SetControlPos hd, SWP_MOVEHIDE, fdlgIDCANCEL
      GetWindowRect hd, tR
        
      '// Open Button
      hd = GetDlgItem(m_hwnd, fdlgIDOK)
      SetControlPos hd, SWP_MOVEHIDE, fdlgIDOK
        
      '// Read-Only CheckBox
      hd = GetDlgItem(m_hwnd, fdlgChxReadOnly)
      SetControlPos hd, SWP_MOVEHIDE
      EnableWindow hd, False
  
      '// FileType TextBox
      hd = GetDlgItem(m_hwnd, fdlgcmbSaveAsType)
      SetControlPos hd, SWP_MOVEHIDE
        
      '// FileType Label
      hd = GetDlgItem(m_hwnd, fdlgStcSaveAsType)
      SetControlPos hd, SWP_MOVEHIDE
        
      '// FileName TxtBox
      hd = GetDlgItem(m_hwnd, fdlgEdtFileName)
      SetControlPos hd, SWP_MOVEHIDE
        
      '// FileName Label
      hd = GetDlgItem(m_hwnd, fdlgStcFileName)
      SetControlPos hd, SWP_MOVEHIDE
          
      '// ListBoxLb
      hd = GetDlgItem(m_hwnd, fdlgLBLstFiles)
      SetControlPos hd, SWP_MOVEHIDE
      EnableWindow hd, True
      
      '// Find ComboBox:
      hd = GetDlgItem(m_hwnd, fdlgCmbSaveInFindIn)
      SetControlPos hd, SWP_MOVEHIDE
          
      '// Find In Label:
      hd = GetDlgItem(m_hwnd, fdlgStcSaveInFindIn)
      SetControlPos hd, SWP_MOVEHIDE
          
      '// Tool Bar
      Tbhwnd = FindWindowEx(m_hwnd, 0&, "ToolbarWindow32", vbNullString)
      SetControlPos Tbhwnd, SWP_MOVEHIDE Or SWP_NOZORDER
  
   Else
        
      '// Cancel Button
      hd = GetDlgItem(m_hwnd, fdlgIDCANCEL)
      SetControlPos hd, SWP_NOSIZE
      GetWindowRect hd, tR
          
      '// Open Button
      hd = GetDlgItem(m_hwnd, fdlgIDOK)
      SetControlPos hd, SWP_NOSIZE
          
      '// Read-Only CheckBox
      hd = GetDlgItem(m_hwnd, fdlgChxReadOnly)
      SetControlPos hd, SWP_MOVEHIDE
      EnableWindow hd, False
      
      '// FileType TextBox
      hd = GetDlgItem(m_hwnd, fdlgcmbSaveAsType)
      SetControlPos hd, SWP_NOSIZE
          
      '// FileType Label
      hd = GetDlgItem(m_hwnd, fdlgStcSaveAsType)
      SetControlPos hd, SWP_NOSIZE
          
      '// FileName TxtBox
      hd = GetDlgItem(m_hwnd, fdlgEdtFileName)
      SetControlPos hd, SWP_NOSIZE
          
      '// FileName Label
      hd = GetDlgItem(m_hwnd, fdlgStcFileName)
      SetControlPos hd, SWP_NOSIZE
          
      '// ListBoxLb
      hd = GetDlgItem(m_hwnd, fdlgLBLstFiles)
      SetControlPos hd, SWP_NOSIZE
      EnableWindow hd, True
      
      '// Find ComboBox:
      hd = GetDlgItem(m_hwnd, fdlgCmbSaveInFindIn)
      SetControlPos hd, SWP_NOSIZE
          
      '// Find In Label:
      hd = GetDlgItem(m_hwnd, fdlgStcSaveInFindIn)
      SetControlPos hd, SWP_NOSIZE
          
      '// Tool Bar
      Tbhwnd = FindWindowEx(m_hwnd, 0&, "ToolbarWindow32", vbNullString)
      SetControlPos Tbhwnd, SWP_NOSIZE Or SWP_NOZORDER
    
   End If
  
   'Resize dialog to [me.height & me.width] then center
   lW = tR.Right - tTR.Left + (tabMain.ClientLeft * 2 + Me.Width -
    Me.ScaleWidth) \ Screen.TwipsPerPixelX
   lH = (m_Controls.Top + tabMain.Top + tabMain.Height + chkDont.Height +
    Me.Height - Me.ScaleHeight) \ Screen.TwipsPerPixelY + 8
   chkDont.Move chkDont.Left, tabMain.Height + tabMain.Top + 4 *
    Screen.TwipsPerPixelY
   MoveWindow m_hwnd, 0&, 0&, lW + 4, lH + 8, 0
   'Center it
   cD.CentreDialog hDlg, Screen
   m_Controls.Width = lW * Screen.TwipsPerPixelX - (Me.Width - Me.ScaleWidth)
   tabMain.Width = m_Controls.Width
   imgSplash.Width = tabMain.Width
   

   'move our controls container to dialog
   SetParent m_Controls.hWnd, m_hwnd
      
   InstallHook

End Sub
Private Sub chkDont_Click()
   m_bShowNew = Not m_bShowNew
End Sub

Private Sub CmdNewCancel_Click()
   Form_QueryUnload 0, 0
End Sub

Private Sub cmdNewOpen_Click()
   If lvwNew.SelectedItem Is Nothing Then Exit Sub
   
   m_sFileName = lvwNew.SelectedItem.Text
   m_bCancel = False
   Form_QueryUnload 0, 0
   
End Sub

Private Sub Form_Load()

Dim itmX As ListItem
Dim i As Long

    
    ' Signal default of cancelled:
    m_bCancel = True
    
    ' Form initialisation:
    If Not (m_ilsNew Is Nothing) Then
        lvwNew.Icons = m_ilsNew
    End If
    
   If m_bShowNew Then
      tabMain.Top = imgSplash.Top + imgSplash.Height + 4 * Screen.TwipsPerPixelY
   Else
      tabMain.Top = imgSplash.Top
   End If
   lvwNew.Top = tabMain.ClientTop + 2 * Screen.TwipsPerPixelY
   lvwRecent.Top = tabMain.ClientTop + 2 * Screen.TwipsPerPixelY
    
    
    If m_bShowNew Then
     For i = 1 To m_iNewCount
        Set itmX = lvwNew.ListItems.Add(, , m_sNewName(i), m_vNewIcon(i))
        If (i = 1) Then
            itmX.Selected = True
            m_sFileName = lvwNew.SelectedItem.Text
        End If
     Next i
    End If
    
    If Not (m_ilsExist Is Nothing) Then
        lvwRecent.SmallIcons = m_ilsExist
    End If
    
    For i = 1 To m_iExistCOunt
        Set itmX = lvwRecent.ListItems.Add(, , m_sExistName(i), ,
         m_vExistIcon(i))
        itmX.SubItems(1) = m_sExistFolder(i)
        itmX.SubItems(2) = m_dExistDate(i)
        If (i = 1) Then
            itmX.Selected = True
        End If
    Next i
    
   If Not (m_bShowNew) Then
      imgSplash.Visible = False
      imgVBAccelerator.Visible = False
      lblSplash.Visible = False
      tabMain.Tabs.Remove 1
      lvwNew.Visible = False
      cmdNewOpen.Visible = False
      CmdNewCancel.Visible = False
   Else
      imgSplash.Visible = True
      imgVBAccelerator.Visible = True
      lblSplash.Visible = True
      m_bIsNew = True
      lvwNew.Visible = True
      cmdNewOpen.Visible = True
      CmdNewCancel.Visible = True
      
   End If
    
End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   If (m_hwnd <> 0) And (m_hDlg <> 0) Then
      ' Cancel Common Dialog box if loaded:
      
      'Put m_Controls back on Me
      SetParent m_Controls.hWnd, Me.hWnd
      
      ' Send Close command to the dialog:
      SendMessageLong m_hwnd, WM_COMMAND, fdlgIDCANCEL, 1
      SendMessageLong m_hDlg, WM_CLOSE, 0, 0
      SendMessageLong m_hwnd, WM_CLOSE, 0, 0
      m_hwnd = 0: m_hDlg = 0
   End If
    
   RemoveHook
   
End Sub

Private Sub Form_Resize()
   Debug.Print
End Sub

Private Sub lvwNew_DblClick()
 
   If Not (lvwNew.SelectedItem Is Nothing) And Not (lvwNew.DropHighlight Is
    Nothing) Then
      cmdNewOpen.Value = True
   End If
 
End Sub


Private Sub lvwNew_ItemClick(ByVal Item As ComctlLib.ListItem)
   m_sFileName = Item.Text
End Sub

Private Sub lvwNew_MouseDown(Button As Integer, Shift As Integer, X As Single,
 Y As Single)
 
   If Button = vbLeftButton Then
      lvwNew.DropHighlight = lvwNew.HitTest(X, Y)
   End If
 
End Sub


Private Sub lvwRecent_DblClick()
   If Not (lvwRecent.SelectedItem Is Nothing) And Not (lvwRecent.DropHighlight
    Is Nothing) Then
      m_sFileName = lvwRecent.SelectedItem.Text
      SendMessageLong m_hwnd, WM_COMMAND, fdlgIDOK, 1
   End If
  
End Sub

Private Sub lvwRecent_ItemClick(ByVal Item As ComctlLib.ListItem)
' Recent item:
   m_sFileName = Item.SubItems(1)
   If (Right$(m_sFileName, 1) <> "\") Then m_sFileName = m_sFileName & "\"
   m_sFileName = m_sFileName & Item.Text
   SetDlgItemText m_hwnd, fdlgEdtFileName, m_sFileName
End Sub


Private Sub lvwRecent_MouseDown(Button As Integer, Shift As Integer, X As
 Single, Y As Single)
   If Button = vbLeftButton Then
      lvwRecent.DropHighlight = lvwRecent.HitTest(X, Y)
   End If
End Sub


Private Sub m_Controls_GotFocus()
   If GetFocusAPI <> tabMain.hWnd Then
  
      If tabMain.SelectedItem.Caption = "New" Then
         'We do this to make cmdnewopen the show as default else it won't
         SetFocusAPI cmdNewOpen.hWnd
      End If
  
     SetFocusAPI tabMain.hWnd
   End If
   
End Sub


Private Sub tabMain_BeforeClick(Cancel As Integer)
   LastTabFocus = tabMain.SelectedItem.Caption
End Sub

Private Sub tabMain_Click()
Dim iTab As String
Dim hd  As Long
   
   ' Show the relevant picture box for the
   ' selected tab:
   iTab = tabMain.SelectedItem.Caption
   If iTab = LastTabFocus Then Exit Sub
      
   Select Case LastTabFocus
   Case "New"
      m_bIsNew = False
      ShowWindow lvwNew.hWnd, 0&
      
      cmdNewOpen.Visible = False
      CmdNewCancel.Visible = False
      
   Case "Existing"
      
      Call GetDlgItemText(m_hwnd, fdlgEdtFileName, TmpFileTxt, 128)
      
      hd = GetDlgItem(m_hwnd, fdlgLVLstFiles)
      ShowWindow hd, 0&
      
      hd = GetDlgItem(m_hwnd, fdlgStcSaveInFindIn)
      ShowWindow hd, 0&
   
      hd = GetDlgItem(m_hwnd, fdlgCmbSaveInFindIn)
      ShowWindow hd, 0&
      EnableWindow hd, 0&
   
      ShowWindow Tbhwnd, 0&
                
      hd = GetDlgItem(m_hwnd, fdlgStcFileName)
      ShowWindow hd, 0&
                
      hd = GetDlgItem(m_hwnd, fdlgEdtFileName)
      ShowWindow hd, 0&
                
      hd = GetDlgItem(m_hwnd, fdlgStcSaveAsType)
      ShowWindow hd, 0&
   
      hd = GetDlgItem(m_hwnd, fdlgcmbSaveAsType)
      ShowWindow hd, 0&
     
   Case "Recent"
      ShowWindow lvwRecent.hWnd, 0&
      
   End Select
    
   Select Case iTab
   Case "New"
      m_bIsNew = True
      ShowWindow lvwNew.hWnd, 1&
      SetFocusAPI tabMain.hWnd
      
      hd = GetDlgItem(m_hwnd, fdlgIDCANCEL)
      ShowWindow hd, 0&
  
      hd = GetDlgItem(m_hwnd, fdlgIDOK)
      ShowWindow hd, 0&
      
      cmdNewOpen.Visible = True
      CmdNewCancel.Visible = True
      
      If Not (lvwNew.SelectedItem Is Nothing) Then
         m_sFileName = lvwNew.SelectedItem.Text
         lvwNew.SelectedItem.Selected = True
      Else
         m_sFileName = ""
      End If
      
      SetFocusAPI tabMain.hWnd
      
   Case "Existing"
      hd = GetDlgItem(m_hwnd, fdlgIDCANCEL)
      ShowWindow hd, 1&
            
      hd = GetDlgItem(m_hwnd, fdlgIDOK)
      ShowWindow hd, 1&
      EnableWindow hd, 1&
      
      hd = GetDlgItem(m_hwnd, fdlgcmbSaveAsType)
      ShowWindow hd, 1&
                     
      hd = GetDlgItem(m_hwnd, fdlgStcSaveAsType)
      ShowWindow hd, 1&
   
      hd = GetDlgItem(m_hwnd, fdlgEdtFileName)
      ShowWindow hd, 1&
    
      hd = GetDlgItem(m_hwnd, fdlgStcFileName)
      ShowWindow hd, 1&
               
      hd = GetDlgItem(m_hwnd, fdlgLVLstFiles)
      ShowWindow hd, 1&
      
      hd = GetDlgItem(m_hwnd, fdlgCmbSaveInFindIn)
      ShowWindow hd, 1&
      EnableWindow hd, True
    
      hd = GetDlgItem(m_hwnd, fdlgStcSaveInFindIn)
      ShowWindow hd, 1&
  
      ShowWindow Tbhwnd, 1
                
      m_sFileName = TmpFileTxt
    
      SetFocusAPI tabMain.hWnd
      SetDlgItemText m_hwnd, fdlgEdtFileName, TmpFileTxt
      
   Case "Recent"
            
      hd = GetDlgItem(m_hwnd, fdlgIDCANCEL)
      ShowWindow hd, 1&
            
      hd = GetDlgItem(m_hwnd, fdlgIDOK)
      ShowWindow hd, 1&
      
      ShowWindow lvwRecent.hWnd, 1&
      SetFocusAPI tabMain.hWnd
      
      If lvwRecent.ListItems.Count = 0 Then
         hd = GetDlgItem(m_hwnd, fdlgIDOK)
         EnableWindow hd, 0&
         ShowWindow hd, 0&
         m_sFileName = ""
      Else
         If Not (lvwRecent.SelectedItem Is Nothing) Then
            m_sFileName = lvwRecent.SelectedItem.SubItems(1)
            If (Right$(m_sFileName, 1) <> "\") Then m_sFileName = m_sFileName &
             "\"
            m_sFileName = m_sFileName & lvwRecent.SelectedItem.Text
         Else
            m_sFileName = ""
         End If
      End If
      
      If Not (lvwRecent.SelectedItem Is Nothing) Then
         lvwRecent.SelectedItem.Selected = True
      End If
   
      SetDlgItemText m_hwnd, fdlgEdtFileName, m_sFileName
   End Select
    
    
End Sub

Public Property Get ShowNew() As Boolean
    ShowNew = m_bShowNew
End Property
Public Property Get IsNew() As Boolean
    IsNew = m_bIsNew
End Property
Public Sub AddNewType(ByVal sName As String, Optional ByVal vIcon As Variant)
    m_iNewCount = m_iNewCount + 1
    ReDim Preserve m_sNewName(1 To m_iNewCount) As String
    ReDim Preserve m_vNewIcon(1 To m_iNewCount) As Variant
    m_sNewName(m_iNewCount) = sName
    m_vNewIcon(m_iNewCount) = vIcon
End Sub
Public Sub AddExistItem(ByVal sName As String, ByVal sFOlder As String, ByVal
 dDate As Date, Optional ByVal vIcon As Variant)
    m_iExistCOunt = m_iExistCOunt + 1
    ReDim Preserve m_sExistName(1 To m_iExistCOunt) As String
    ReDim Preserve m_sExistFolder(1 To m_iExistCOunt) As String
    ReDim Preserve m_dExistDate(1 To m_iExistCOunt) As Date
    ReDim Preserve m_vExistIcon(1 To m_iExistCOunt) As Variant
    m_sExistName(m_iExistCOunt) = sName
    m_sExistFolder(m_iExistCOunt) = sFOlder
    m_dExistDate(m_iExistCOunt) = dDate
    m_vExistIcon(m_iExistCOunt) = vIcon
End Sub
Public Property Let NewImageList(ByRef ilsThis As ImageList)
    Set m_ilsNew = ilsThis
End Property
Public Property Let ExistingImageList(ByRef ilsThis As ImageList)
    Set m_ilsExist = ilsThis
End Property

Public Property Let ShowNew(ByVal bShow As Boolean)
    m_bShowNew = bShow
End Property

Public Property Get Cancelled() As Boolean
    Cancelled = m_bCancel
End Property
Public Property Get FileName() As String
    ' Property to allow the caller to retrieve the
    ' selected file name:
    FileName = m_sFileName
End Property


Private Sub tmrUnload_Timer()
   Unload Me
End Sub