VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{DC8DEC8D-0714-4F8D-9D0F-DF49898C68C4}#9.0#0"; "GridPlus.ocx"
Begin VB.Form frmEditForms 
   Caption         =   "Form1"
   ClientHeight    =   7230
   ClientLeft      =   60
   ClientTop       =   405
   ClientWidth     =   9630
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   7230
   ScaleWidth      =   9630
   StartUpPosition =   1  'CenterOwner
   Begin MSComDlg.CommonDialog cmDialog 
      Left            =   8520
      Top             =   1200
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdOpenVBP 
      Caption         =   "Abrir VBP"
      Height          =   360
      Left            =   8220
      TabIndex        =   7
      Top             =   360
      Width           =   990
   End
   Begin VB.Frame Frame3 
      Caption         =   "Detalle Control"
      Height          =   2640
      Left            =   7635
      TabIndex        =   4
      Top             =   4110
      Width           =   5295
      Begin VB.TextBox txtControl 
         Height          =   2310
         Left            =   105
         MultiLine       =   -1  'True
         TabIndex        =   5
         Top             =   210
         Width           =   4515
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Controles Formulario"
      Height          =   2640
      Left            =   60
      TabIndex        =   3
      Top             =   3975
      Width           =   7110
      Begin VB.CommandButton cmdAddColumn 
         Caption         =   "add"
         Height          =   360
         Left            =   6480
         TabIndex        =   9
         Top             =   180
         Width           =   570
      End
      Begin GridPlusOCX.GridPlus gpControls 
         Height          =   2220
         Left            =   120
         TabIndex        =   8
         Top             =   300
         Width           =   6840
         _ExtentX        =   12065
         _ExtentY        =   3916
         AllowRowsResize =   0   'False
         ShowHotColumn   =   0   'False
         ColumnsAutoFit  =   -1  'True
         ColsCount       =   2
         RowsCount       =   2
         HeaderHeight    =   25
         SelectionMode   =   3
         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
         BeginProperty HeaderFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllowEdit       =   0   'False
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Formularios del Proyecto"
      Height          =   3885
      Left            =   60
      TabIndex        =   0
      Top             =   30
      Width           =   7905
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   720
         TabIndex        =   6
         Top             =   240
         Width           =   6975
      End
      Begin VB.ListBox ListF 
         Height          =   2985
         Left            =   120
         TabIndex        =   2
         Top             =   720
         Width           =   7650
      End
      Begin VB.ListBox lvForms 
         Height          =   3375
         Left            =   135
         TabIndex        =   1
         Top             =   240
         Visible         =   0   'False
         Width           =   135
      End
   End
End
Attribute VB_Name = "frmEditForms"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim TextLine As String
Dim sPath As String
Dim sProjectPath As String
Dim I As Integer


Private Function ReadForms1(sFormPath As String)
Dim FileH As Integer
Dim sWord() As String
Dim R As Long, C As Long
Dim CleanLine As String
Dim sChar As String, iSpace As Integer

FileH = FreeFile

Debug.Print sFormPath

If Dir(sFormPath) <> "" Then

  Open sFormPath For Input As #FileH
  
  Frame2.Caption = lvForms.Text & " controls"
  
  C = 0: R = 0
  
  Do Until Left$(TextLine, 9) = "Attribute"           ' Loop until = <cond>
    If Left$(TextLine, 9) = "Attribute" Then Exit Do
    Line Input #FileH, TextLine$                      ' Read line into variable
    TextLine = Trim$(TextLine)
    CleanLine = ""
    iSpace = 0
    For I = 1 To Len(TextLine)
        sChar = Mid$(TextLine, I, 1)
        If sChar = " " And iSpace = 0 Then
          sChar = " "
          iSpace = iSpace + 1
        ElseIf sChar = " " And iSpace > 0 Then
          sChar = ""
          iSpace = iSpace + 1
        Else
          iSpace = 0
        End If
        CleanLine = CleanLine & sChar
    Next I
    'Debug.Print CleanLine
    sWord = Split(CleanLine, Space$)
      
      If Trim$(sWord(0)) = "Begin" Then
        If Trim$(sWord(1)) <> "VB.MDIForm" And Trim$(sWord(1)) <> "VB.Form" Then
          With gpControls
            .Redraw = False
            .ColsCount = .ColsCount + 1
            C = .ColsCount - 1
            .ColumnText(C) = sWord(1)
            .CellValue(0, C) = "NAME=" & sWord(2)
            .Redraw = True
          End With
        End If
      Else

      End If
  Loop
  
  Close #FileH
  
End If

End Function

Private Function ReadForms(sFormPath As String)
Dim FSO As Object
Dim SourceF As Object
Dim sLine As String
Dim sShortPath As String

sShortPath = fGetDOSPath(sFormPath)
Debug.Print sShortPath

Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceF = FSO.OpenTextFile(sShortPath, ForReading, False, TristateFalse)

While Not SourceF.AtEndOfStream                   ' while we are not finished reading through the file
    
    Do Until Left$(sLine, 9) = "Attribute"        ' Loop until = <cond>
      sLine = SourceF.ReadLine                    ' Read line into variable
      If Left$(sLine, 4) = "Form" Then
        lvForms.AddItem Mid$(sLine, 6, Len(sLine))
      End If
    Loop

Wend
SourceF.Close
Set FSO = Nothing
End Function

Private Function LoadForms()
Dim FileHandle As Integer

FileHandle = FreeFile
Open sProjectPath For Input As #FileHandle

Frame1.Caption = "VB6 Project: " & sProjectPath
sPath = GetDirectoryFromPath(sProjectPath)

Do While Not EOF(FileHandle)        ' Loop until end of file
  Line Input #FileHandle, TextLine$  ' Read line into variable

  If Left$(TextLine, 4) = "Form" Then
    lvForms.AddItem Mid$(TextLine, 6, Len(TextLine))
  End If
Loop

Close #FileHandle

For I = 0 To lvForms.ListCount - 1
  lvForms.ListIndex = I
  If Left$(lvForms.Text, 3) = "..\" Then
    ListF.AddItem GetDirectoryFromPath(Left$(sPath, Len(sPath) - 1)) & Mid$(lvForms.Text, 4, Len(lvForms.Text))
  Else
    ListF.AddItem sPath & lvForms.Text
  End If
Next I

End Function

Private Sub cmdAddColumn_Click()
With gpControls
  
  

End With
End Sub

Private Sub cmdOpenVBP_Click()
With cmDialog
  .DialogTitle = "Open VB6 Project File"
  .Filter = "VB6 Project File|*.vbp"
  .ShowOpen
  
  sProjectPath = .FileName
  
  Call LoadForms

End With
End Sub

Private Sub ListF_Click()
lvForms.ListIndex = ListF.ListIndex
Text1.Text = ListF.Text

End Sub

Private Sub ListF_DblClick()
Call ReadForms1(Text1.Text)
End Sub

Public Function GetDirectoryFromPath(FullPath As String) As String
'Returns "E:\VideoPaper\Videos\".
   GetDirectoryFromPath = Left(FullPath, InStrRev(FullPath, "\"))
End Function

Public Function GetFilenameFromPath(FullPath As String) As String
'Returns "Atomic Kitten - Whole Again.mpg".
   GetFilenameFromPath = Right(FullPath, Len(FullPath) - InStrRev(FullPath, "\"))
End Function

