home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 3_2004-2005.ISO / Data / Zips / VB_binary_184694212005.psc / ExtractVB.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  2005-02-01  |  28.5 KB  |  806 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmExtractVB 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Extract images from VB binary support files"
  6.    ClientHeight    =   6000
  7.    ClientLeft      =   45
  8.    ClientTop       =   630
  9.    ClientWidth     =   12270
  10.    Icon            =   "ExtractVB.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    NegotiateMenus  =   0   'False
  15.    ScaleHeight     =   6000
  16.    ScaleMode       =   0  'User
  17.    ScaleWidth      =   12270
  18.    StartUpPosition =   1  'CenterOwner
  19.    Begin VB.Frame fraDisplay 
  20.       Height          =   6000
  21.       Left            =   6240
  22.       TabIndex        =   7
  23.       Top             =   0
  24.       Width           =   6000
  25.       Begin VB.PictureBox picContainer 
  26.          BackColor       =   &H8000000C&
  27.          BorderStyle     =   0  'None
  28.          Height          =   5505
  29.          Left            =   120
  30.          ScaleHeight     =   5505
  31.          ScaleWidth      =   5595
  32.          TabIndex        =   10
  33.          Top             =   240
  34.          Width           =   5595
  35.          Begin VB.PictureBox picDisplay 
  36.             AutoRedraw      =   -1  'True
  37.             AutoSize        =   -1  'True
  38.             BackColor       =   &H8000000C&
  39.             BorderStyle     =   0  'None
  40.             Height          =   3210
  41.             Left            =   720
  42.             ScaleHeight     =   3210
  43.             ScaleWidth      =   3975
  44.             TabIndex        =   11
  45.             Top             =   840
  46.             Width           =   3975
  47.          End
  48.       End
  49.       Begin VB.VScrollBar vscDisplay 
  50.          Enabled         =   0   'False
  51.          Height          =   5505
  52.          LargeChange     =   500
  53.          Left            =   5760
  54.          SmallChange     =   150
  55.          TabIndex        =   9
  56.          Top             =   225
  57.          Width           =   150
  58.       End
  59.       Begin VB.HScrollBar hscDisplay 
  60.          Enabled         =   0   'False
  61.          Height          =   150
  62.          LargeChange     =   500
  63.          Left            =   -30
  64.          TabIndex        =   8
  65.          Top             =   5760
  66.          Width           =   5835
  67.       End
  68.    End
  69.    Begin MSComDlg.CommonDialog cdlExtract 
  70.       Left            =   3960
  71.       Top             =   2880
  72.       _ExtentX        =   847
  73.       _ExtentY        =   847
  74.       _Version        =   393216
  75.    End
  76.    Begin VB.Frame fraExtractVB 
  77.       Height          =   4935
  78.       Left            =   0
  79.       TabIndex        =   0
  80.       Top             =   0
  81.       Width           =   6195
  82.       Begin VB.PictureBox picCFXPBugFixfrmExtractVB 
  83.          BorderStyle     =   0  'None
  84.          Height          =   4680
  85.          Left            =   120
  86.          ScaleHeight     =   4680
  87.          ScaleWidth      =   6000
  88.          TabIndex        =   1
  89.          Top             =   175
  90.          Width           =   6000
  91.          Begin VB.CommandButton cmdDelete 
  92.             Caption         =   "Delete >"
  93.             Enabled         =   0   'False
  94.             Height          =   285
  95.             Left            =   5040
  96.             TabIndex        =   19
  97.             ToolTipText     =   "Delete the file displayed in the main image."
  98.             Top             =   2760
  99.             Width           =   885
  100.          End
  101.          Begin VB.CommandButton cmdAbort 
  102.             Cancel          =   -1  'True
  103.             Caption         =   "Abort"
  104.             Enabled         =   0   'False
  105.             Height          =   285
  106.             Left            =   2760
  107.             TabIndex        =   18
  108.             Top             =   2760
  109.             Width           =   885
  110.          End
  111.          Begin VB.PictureBox picGuage 
  112.             AutoRedraw      =   -1  'True
  113.             BackColor       =   &H00FFFFFF&
  114.             DrawMode        =   7  'Invert
  115.             FillColor       =   &H000000FF&
  116.             ForeColor       =   &H000000FF&
  117.             Height          =   285
  118.             Left            =   0
  119.             ScaleHeight     =   225
  120.             ScaleWidth      =   5880
  121.             TabIndex        =   13
  122.             Top             =   4395
  123.             Width           =   5940
  124.          End
  125.          Begin VB.CommandButton cmdStartExtraction 
  126.             Caption         =   "Start Extraction"
  127.             Enabled         =   0   'False
  128.             Height          =   285
  129.             Left            =   0
  130.             TabIndex        =   12
  131.             Top             =   2760
  132.             Width           =   2085
  133.          End
  134.          Begin VB.CommandButton cmdExtractFrom 
  135.             Caption         =   "Extract From..."
  136.             Height          =   285
  137.             Left            =   0
  138.             TabIndex        =   5
  139.             ToolTipText     =   "Select frm, dob and ctl files to search for images."
  140.             Top             =   0
  141.             Width           =   1725
  142.          End
  143.          Begin VB.CommandButton cmdChangeDestination 
  144.             Caption         =   "Change Destination folder..."
  145.             Enabled         =   0   'False
  146.             Height          =   285
  147.             Left            =   0
  148.             TabIndex        =   4
  149.             ToolTipText     =   "By default files are created in source file folder"
  150.             Top             =   1800
  151.             Width           =   2565
  152.          End
  153.          Begin VB.TextBox txtDestination 
  154.             Enabled         =   0   'False
  155.             Height          =   285
  156.             Left            =   5
  157.             Locked          =   -1  'True
  158.             TabIndex        =   3
  159.             TabStop         =   0   'False
  160.             Top             =   2070
  161.             Width           =   5985
  162.          End
  163.          Begin VB.ListBox lstSource 
  164.             Height          =   1230
  165.             Left            =   5
  166.             TabIndex        =   2
  167.             TabStop         =   0   'False
  168.             Top             =   250
  169.             Width           =   5985
  170.          End
  171.          Begin VB.PictureBox picHolder 
  172.             Height          =   720
  173.             Left            =   0
  174.             ScaleHeight     =   660
  175.             ScaleWidth      =   5880
  176.             TabIndex        =   14
  177.             Top             =   3360
  178.             Width           =   5940
  179.             Begin VB.HScrollBar HScroll 
  180.                Enabled         =   0   'False
  181.                Height          =   240
  182.                Left            =   0
  183.                TabIndex        =   16
  184.                Top             =   420
  185.                Width           =   5880
  186.             End
  187.             Begin VB.PictureBox picThumbnail 
  188.                BorderStyle     =   0  'None
  189.                Height          =   420
  190.                Left            =   0
  191.                ScaleHeight     =   420
  192.                ScaleWidth      =   420
  193.                TabIndex        =   15
  194.                TabStop         =   0   'False
  195.                Top             =   0
  196.                Width           =   420
  197.                Begin VB.Shape shpSelector 
  198.                   BorderColor     =   &H000080FF&
  199.                   BorderStyle     =   2  'Dash
  200.                   BorderWidth     =   5
  201.                   Height          =   495
  202.                   Left            =   0
  203.                   Top             =   120
  204.                   Visible         =   0   'False
  205.                   Width           =   615
  206.                End
  207.                Begin VB.Image imgThumbnail 
  208.                   Height          =   420
  209.                   Index           =   0
  210.                   Left            =   0
  211.                   Stretch         =   -1  'True
  212.                   Top             =   0
  213.                   Visible         =   0   'False
  214.                   Width           =   420
  215.                End
  216.             End
  217.          End
  218.          Begin VB.Label lblExtractVB 
  219.             Alignment       =   2  'Center
  220.             Height          =   210
  221.             Left            =   -600
  222.             TabIndex        =   17
  223.             Top             =   4140
  224.             UseMnemonic     =   0   'False
  225.             Width           =   2820
  226.          End
  227.       End
  228.    End
  229.    Begin VB.Label lblFileDescription 
  230.       BorderStyle     =   1  'Fixed Single
  231.       Height          =   855
  232.       Left            =   0
  233.       TabIndex        =   6
  234.       Top             =   5040
  235.       Width           =   6135
  236.    End
  237.    Begin VB.Menu mnuFile 
  238.       Caption         =   "&File"
  239.       Begin VB.Menu mnuExit 
  240.          Caption         =   "E&xit"
  241.       End
  242.    End
  243.    Begin VB.Menu mnuHelp 
  244.       Caption         =   "&Help"
  245.    End
  246. Attribute VB_Name = "frmExtractVB"
  247. Attribute VB_GlobalNameSpace = False
  248. Attribute VB_Creatable = False
  249. Attribute VB_PredeclaredId = True
  250. Attribute VB_Exposed = False
  251. Option Explicit
  252. Private bProcessing                 As Boolean
  253. Private bAbort                      As Boolean
  254. Private sSource()                   As String
  255. Private nImageCount                 As Long
  256. Private CurImage                    As Long
  257. Private Type ImageData
  258.   ipath                             As String
  259.   iName                             As String
  260.   iExt                              As String
  261.   iKB                               As Long
  262.   iHieght                           As Long
  263.   iWidth                            As Long
  264.   iType                             As Long
  265.   iThumbID                          As Long
  266. End Type
  267. Private PicData()                   As ImageData
  268. Private ScrollPic                   As New ClsScrollPicture
  269. ' ListBox Tooltips control
  270. Private Const LB_ITEMFROMPOINT      As Long = &H1A9
  271. Private strBaseCaption              As String
  272. Private Declare Function SendLBMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
  273.                                                                           ByVal wMsg As Long, _
  274.                                                                           ByVal wParam As Long, _
  275.                                                                           lParam As Any) As Long
  276. Private Declare Sub InitCommonControls Lib "comctl32" ()
  277. Private Sub CaptionComment(ByVal strCom As String)
  278.   Caption = strBaseCaption & IIf(Len(strCom), "...", vbNullString) & strCom
  279. End Sub
  280. Private Sub ClearForExtraction()
  281.   Dim I As Long
  282.   bAbort = False
  283.   cmdStartExtraction.Enabled = False
  284.   cmdAbort.Enabled = True
  285.   ProgressBar 0
  286.   For I = imgThumbnail.Count - 1 To 1 Step -1
  287.     Unload imgThumbnail(I)
  288.   Next I
  289.   imgThumbnail(0).Visible = True
  290.   picThumbnail.Width = 1
  291.   HScroll.Enabled = False
  292.   lblExtractVB.Caption = "No images extracted"
  293.   Erase PicData
  294. End Sub
  295. Private Sub cmdAbort_Click()
  296.   If bProcessing Then
  297.     bAbort = True
  298.     DoEvents
  299.    Else
  300.     Unload Me
  301.   End If
  302. End Sub
  303. Private Sub cmdChangeDestination_Click()
  304.   Dim sFolder As String
  305.   sFolder = FolderBrowser("Select destination folder for the images:", Me.hWnd)
  306.   If LenB(sFolder) Then
  307.     txtDestination.Text = sFolder
  308.     Set_OK_State
  309.   End If
  310. End Sub
  311. Private Sub cmdDelete_Click()
  312.   On Error Resume Next
  313.   If LenB(PicData(CurImage).iName) Then
  314.     cmdDelete.Enabled = False
  315.     Kill PicData(CurImage).ipath & "\" & PicData(CurImage).iName
  316.     With PicData(CurImage)
  317.       .iExt = ""
  318.       .iHieght = 0
  319.       .iKB = 0
  320.       .iName = ""
  321.       .ipath = ""
  322.       .iType = 0
  323.       .iWidth = 0
  324.       If .iThumbID > 0 Then
  325.         Unload imgThumbnail(.iThumbID)
  326.        Else
  327.         imgThumbnail(.iThumbID).Visible = False
  328.       End If
  329.     End With
  330.     PositionThumbs
  331.     lblFileDescription.Caption = ""
  332.     picDisplay = LoadPicture()
  333.     If CurImage > 0 And CurImage < imgThumbnail.Count Then
  334.       imgThumbnail_Click CInt(CurImage + 1)
  335.      Else
  336.       If CurImage > 1 Then
  337.         imgThumbnail_Click CInt(CurImage - 1)
  338.       End If
  339.     End If
  340.   End If
  341.   On Error GoTo 0
  342. End Sub
  343. Private Sub cmdExtractFrom_Click()
  344.   Dim n         As Long
  345.   Dim sFolder   As String
  346.   Dim I         As Long
  347.   Dim sFileName As String
  348.   Dim nCount    As Long
  349.   On Error GoTo PickSourceCancelled
  350.   With cdlExtract
  351.     .DialogTitle = "Open VB files"
  352.     'Fixed thanks Tony
  353.     .Filter = "VB binary support files(*.frx;*.dox;*.ctx;*.dsx;*.pax)|*.frx;*.dox;*.ctx;*.dsx;*.pax"
  354.     .FilterIndex = 1
  355.     .CancelError = True
  356.     .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
  357.     .FileName = ""
  358.     .MaxFileSize = 5120
  359.     .ShowOpen
  360.     .CancelError = False
  361.     sFileName = .FileName
  362.   End With
  363.   If LenB(sFileName) Then
  364.     ' Build sSource() array
  365.     nCount = 0
  366.     Erase sSource
  367.     cmdChangeDestination.Enabled = True
  368.     n = InStr(sFileName, vbNullChar)
  369.     If n > 0 Then   ' Multi-select
  370.       ' First one is the folder
  371.       sFolder = Left$(sFileName, n - 1)
  372.       txtDestination.Text = sFolder
  373.       sFileName = Mid$(sFileName, n + 1)
  374.       ' The rest are the files
  375.       Do While n > 0
  376.         n = InStr(sFileName, vbNullChar)
  377.         ReDim Preserve sSource(0 To nCount)
  378.         If n = 0 Then
  379.           sSource(nCount) = AttachPath(sFileName, sFolder)
  380.          Else
  381.           sSource(nCount) = AttachPath(Left$(sFileName, n - 1), sFolder)
  382.           sFileName = Mid$(sFileName, n + 1)
  383.         End If
  384.         nCount = nCount + 1
  385.       Loop
  386.      Else            ' Single file...
  387.       ReDim sSource(0)
  388.       sSource(0) = sFileName
  389.       txtDestination.Text = Left$(sFileName, InStrRev(sFileName, "\"))
  390.       nCount = 1
  391.     End If
  392.     ' Fill listbox
  393.     With lstSource
  394.       .Clear
  395.       For I = 0 To (nCount - 1)
  396.         If SourceFileExists(sSource(I)) Then
  397.           'Fixed this stops binary files loading if the main form is missing Thanks Tony
  398.           .AddItem ExtractFileName(sSource(I))
  399.           .ItemData(.NewIndex) = I
  400.          Else
  401.           MsgBox "The file '" & ConvertXfileToMainFile(ExtractFileName(sSource(I))) & "' is missing so the binary file will not be loaded."
  402.           sSource(I) = ""
  403.         End If
  404.       Next I
  405.     End With
  406.     Set_OK_State
  407.   End If
  408. PickSourceCancelled:
  409.   cdlExtract.CancelError = False
  410. End Sub
  411. Private Function SourceFileExists(strFname As String) As Boolean
  412.   SourceFileExists = FileExist(ConvertXfileToMainFile(strFname))
  413. End Function
  414. Private Sub cmdStartExtraction_Click()
  415.   ExtractImages
  416.   cmdDelete.Enabled = True
  417. End Sub
  418. Private Function ConvertXfileToMainFile(varFile As Variant) As String
  419.   '*.frm;*.dob;*.ctl;*.dsr;*pag
  420.   Select Case LCase$(Right$(varFile, 4))
  421.    Case ".frx"
  422.     ConvertXfileToMainFile = Left$(varFile, Len(varFile) - 3) & "frm"
  423.    Case ".dox"
  424.     ConvertXfileToMainFile = Left$(varFile, Len(varFile) - 3) & "dob"
  425.    Case ".ctx"
  426.     ConvertXfileToMainFile = Left$(varFile, Len(varFile) - 3) & "ctl"
  427.    Case ".drx"
  428.     ConvertXfileToMainFile = Left$(varFile, Len(varFile) - 3) & "dsr"
  429.    Case ".pax"
  430.     ConvertXfileToMainFile = Left$(varFile, Len(varFile) - 3) & "pag"
  431.   End Select
  432. End Function
  433. Private Sub DisplayPicData(ByVal picID As Long)
  434.   With PicData(picID)
  435.     lblFileDescription.Caption = "Path: " & .ipath & vbNewLine & _
  436.                                  "Name: " & .iName & vbNewLine & _
  437.                                  "Size: " & .iKB & "KB   Height: " & .iHieght & "     Width: " & .iWidth & "   Type: " & .iType
  438.   End With
  439. End Sub
  440. ' Icon = "FormFile.frx":0000
  441. '      ^               ^     = Markers
  442. '        |-----------------| = Parameter
  443. ' Returns the image data in a string
  444. Private Function ExtractImage(ByVal sString As String, _
  445.                               sSourceFile As String, _
  446.                               PrevOffset As Long) As String
  447.   Dim nHandle   As Long
  448.   Dim nOffset   As Long
  449.   Dim nFileSize As Long
  450.   Dim nSize     As Long
  451.   Dim sFile     As String
  452.   Dim sData     As String
  453.   Dim sBytes    As String
  454.   Dim bFileOpen As Boolean
  455.   Dim n         As Long
  456.   On Error GoTo EI_ErrorHandler
  457.   n = InStr(sString, ":")
  458.   If n Then
  459.     sFile = AttachPath(StripQuotes(Left$(sString, n - 1)), ExtractPath(sSourceFile))
  460.     If FileExist(sFile) Then
  461.       sString = "&H" & Trim$(Mid$(sString, n + 1))
  462.       nOffset = CLng(sString) + 1 '+ PrevOffset
  463.       PrevOffset = nOffset - 1
  464.       nHandle = FreeFile
  465.       Open sFile For Binary Access Read Shared As #nHandle
  466.       bFileOpen = True
  467.       nFileSize = LOF(nHandle)
  468.       If (nOffset + 12) > nFileSize Then
  469.         GoTo EI_ErrorHandler
  470.       End If
  471.       ' Get the header...
  472.       Seek #nHandle, nOffset
  473.       sData = Mid$(Input$(12, #nHandle), 9, 4)
  474.       ' Byte 9 to 12 (long) contains data size
  475.       sBytes = "&H" & Right$("00" & Hex$(Asc(Mid$(sData, 4, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 3, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 2, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 1, 1))), 2)
  476.       nSize = CLng(sBytes)
  477.       If nSize < 0 Or (nOffset + 11 + nSize) > nFileSize Then
  478.         ' Try 28 byte header
  479.         If (nOffset + 27) > nFileSize Then
  480.           GoTo EI_ErrorHandler
  481.         End If
  482.         ' Get the header...
  483.         Seek #nHandle, nOffset
  484.         sData = Mid$(Input$(28, #nHandle), 25, 4)
  485.         ' Byte 25 to 28 (long) contains data size
  486.         sBytes = "&H" & Right$("00" & Hex$(Asc(Mid$(sData, 4, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 3, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 2, 1))), 2) & Right$("00" & Hex$(Asc(Mid$(sData, 1, 1))), 2)
  487.         nSize = CLng(sBytes)
  488.         If nSize < 0 Or (nOffset + 27 + nSize) > nFileSize Then
  489.           GoTo EI_ErrorHandler
  490.         End If
  491.       End If
  492.       ' Get the data (position: nOffset + 13 - Already in position)
  493.       ExtractImage = Input$(nSize, #nHandle)
  494.       ' That's it, the icon data is obtained
  495.       Close #nHandle
  496.       bFileOpen = False
  497.       '   Else
  498.       ''Fixed not needed any more thanks Tony
  499.       'MsgBox "The file requires an FRX, DOX or CTX file but it is missing"
  500.     End If
  501.     Exit Function
  502. EI_ErrorHandler:
  503.     If bFileOpen Then
  504.       Close #nHandle
  505.     End If
  506.   End If
  507. End Function
  508. Private Sub ExtractImages()
  509.   Dim I                  As Long
  510.   Dim J                  As Long
  511.   Dim K                  As Long
  512.   Dim sFileIn()          As String
  513.   Dim nTotalSize         As Long    ' Total bytes to analyse (all files)
  514.   Dim nReadSize          As Long
  515.   Dim nProgress          As Long
  516.   Dim nCount             As Long
  517.   Dim nInCount           As Long
  518.   Dim strFormName        As String
  519.   Dim strControlName     As String
  520.   Dim strControlIndex    As String
  521.   Dim strControlProperty As String
  522.   Dim sFolder            As String
  523.   Dim sString            As String
  524.   Dim sImageData         As String
  525.   Dim arrHidden          As Variant
  526.   Dim strFindIndex       As String
  527.   'Dim sImageExt  As String
  528.   'Dim n          As Long
  529.   ''Dim bScan      As Boolean
  530.   ClearForExtraction
  531.   On Error GoTo ExtractError
  532.   CaptionComment "Checking source..."
  533.   sFolder = txtDestination.Text
  534.   nCount = UBound(sSource)
  535.   nInCount = 0
  536.   nReadSize = 0
  537.   nImageCount = 0
  538.   'bScan = False
  539.   ' Check of all files are available
  540.   For I = 0 To nCount
  541.     If FileExist(sSource(I)) Then
  542.       ReDim Preserve sFileIn(0 To nInCount)
  543.       sFileIn(nInCount) = ConvertXfileToMainFile(sSource(I))
  544.       nInCount = nInCount + 1
  545.       nTotalSize = nTotalSize + FileLen(sSource(I))
  546.     End If
  547.   Next I
  548.   If bAbort Then
  549.     GoTo ExtractExit
  550.   End If
  551.   If nInCount Then
  552.     CaptionComment "Checking Target..."
  553.     If FolderExist(sFolder) Then
  554.       CaptionComment "Checks OK - Analysing"
  555.       ' Yield to other processes - just in case Cancel is pressed
  556.       DoEvents
  557.       If bAbort Then
  558.         GoTo ExtractExit
  559.       End If
  560.       For I = 0 To (nInCount - 1)
  561.         ' Yield to other processes - just in case Cancel is pressed
  562.         DoEvents
  563.         If bAbort Then
  564.           GoTo ExtractExit
  565.         End If
  566.         CaptionComment "Analysing " & ExtractFileName(sFileIn(I))
  567.         sImageData = ""
  568.         ' Open for for line-input...
  569.         strFormName = ExtractFileName(sFileIn(I), False)
  570.         GetHiddenTxt sFileIn(I), arrHidden
  571.         For J = LBound(arrHidden) To UBound(arrHidden)
  572.           ' Yield to other processes - just in case Cancel is pressed
  573.           ' Update progressbar...
  574.           nProgress = ((nReadSize + UBound(arrHidden)) * 100) / nTotalSize
  575.           ProgressBar IIf(nProgress > 100, 100, nProgress)
  576.           sString = arrHidden(J)
  577.           If MatchString(sString, "BEGIN ") Then
  578.             strControlName = Trim$(Mid$(sString, InStrRev(sString, " ")))
  579.             'search for index for naming purposes
  580.             'this has to be done because the properties are alpha-listed
  581.             'so Down/DisabledPicture would be found before Index was set in Commandbuttons
  582.             strControlIndex = ""
  583.             K = J + 1
  584.             Do
  585.               strFindIndex = UCase$(arrHidden(K))
  586.               If MatchString(strFindIndex, "INDEX ") Then
  587.                 strControlIndex = Trim$(Mid$(strFindIndex, InStrRev(strFindIndex, " ")))
  588.                 Exit Do
  589.               End If
  590.               K = K + 1
  591.               'reached next object or end of data
  592.             Loop Until MatchString(strFindIndex, "BEGIN ") Or K > UBound(arrHidden)
  593.             If InStr(sString, "MSComctlLib.ImageList") Then
  594.               ImgListExtract arrHidden, sFileIn(I), J, K - 1, sImageData, sFolder, strFormName, strControlName, strControlProperty, nImageCount
  595.               J = K
  596.             End If
  597.            ElseIf IsFrxGraphicLine(sString, strControlProperty) Then
  598.             sImageData = GetImageData(sString, sFileIn(I))
  599.           End If
  600.           'found an image so process it
  601.           If LenB(sImageData) Then
  602.             ProcessOneImage sImageData, sFolder, strFormName, strControlName, strControlIndex, strControlProperty, nImageCount
  603.           End If
  604.           'EndOfFileLoop:
  605.           If bAbort Then
  606.             Exit For
  607.           End If
  608.           DoEvents
  609.         Next J
  610.         nReadSize = nReadSize + UBound(arrHidden)
  611.         If bAbort Then
  612.           Exit For
  613.         End If
  614.       Next I
  615.       ProgressBar 100
  616.       CaptionComment "Extraction completed"
  617. ExtractExit:
  618.       On Error Resume Next
  619.       cmdAbort.Enabled = False
  620.       Set_OK_State
  621.      Else
  622.       CaptionComment "Invalid target folder"
  623.       MsgBox "The target folder you specified is invalid. Please select another target folder.", vbExclamation, "Invalid Folder"
  624.     End If
  625.    Else
  626.     CaptionComment "No files to analyse"
  627.     MsgBox "There are no files to analyse. Please create a new list then try again.", vbExclamation, "No Files"
  628.   End If
  629.   CaptionComment ""
  630. Exit Sub
  631. ExtractError:
  632.   MsgBox "Error occurred during extraction. Process aborted." & vbNewLine & _
  633.        "(" & Err.Number & " - " & Err.Description & ")", vbCritical, "Extract Error"
  634.   ProgressBar 0
  635.   GoTo ExtractExit
  636.   On Error GoTo 0
  637. End Sub
  638. Private Sub Form_Initialize()
  639.   InitCommonControls
  640. End Sub
  641. Private Sub Form_KeyDown(KeyCode As Integer, _
  642.                          Shift As Integer)
  643.   If cmdDelete.Enabled Then
  644.     If KeyCode = vbKeyDelete Then
  645.       cmdDelete_Click
  646.     End If
  647.   End If
  648.   If cmdAbort.Enabled Then
  649.     If KeyCode = vbKeyEscape Then
  650.       cmdAbort_Click
  651.     End If
  652.   End If
  653. End Sub
  654. Private Sub Form_Load()
  655.   strBaseCaption = Caption
  656.   ScrollPic.AssignControls picDisplay, vscDisplay, hscDisplay
  657.   bProcessing = False
  658.   bAbort = False
  659.   nImageCount = 0
  660. End Sub
  661. Private Sub GenerateNewThumb(ByVal nImageCount As Long, _
  662.                              ByVal sImageFile As String)
  663.   On Error Resume Next
  664.   If nImageCount = 0 Then
  665.     imgThumbnail(0).Visible = True
  666.    Else
  667.     Load imgThumbnail(nImageCount)
  668.   End If
  669.   'picThumbnail.Width = 460 * nImageCount
  670.   With imgThumbnail(nImageCount)
  671.     '.Left = 460 * (nImageCount - 1)
  672.     .Picture = picDisplay.Picture
  673.     .ToolTipText = sImageFile
  674.     .Visible = True
  675.   End With
  676.   PositionThumbs
  677.   SelectFrame nImageCount
  678.   On Error GoTo 0
  679. End Sub
  680. Private Sub GeneratePicData(ByVal strFile As String, _
  681.                             strData As String, _
  682.                             ByVal lngID As Long)
  683.   'display the image so that the data can be gathered for PicData
  684.   picDisplay = LoadPicture(strFile)
  685.   ReDim Preserve PicData(lngID) As ImageData
  686.   With PicData(lngID)
  687.     .ipath = Left$(strFile, InStrRev(strFile, "\") - 1)
  688.     .iName = Mid$(strFile, InStrRev(strFile, "\") + 1)
  689.     .iExt = GetImageExtention(strData)
  690.     .iKB = CLng(Len(strData) / 1024)
  691.     .iHieght = ScaleY(picDisplay.Picture.Height)
  692.     .iWidth = ScaleX(picDisplay.Picture.Width)
  693.     .iType = picDisplay.Picture.Type
  694.     .iThumbID = lngID
  695.   End With
  696. End Sub
  697. Private Sub GetHiddenTxt(ByVal strFilename As String, _
  698.                          ArrD As Variant)
  699.   Dim FN      As Long
  700.   Dim strData As String
  701.   Dim strTemp As String
  702.   FN = FreeFile
  703.   Open strFilename For Input Access Read Shared As FN
  704.     Line Input #FN, strTemp
  705.     strData = strData & vbNewLine & Trim$(strTemp)
  706.   Loop Until InStr(strTemp, "Attribute VB_")
  707.   Close FN
  708.   strData = Mid$(strData, 2)
  709.   ArrD = Split(strData, vbNewLine)
  710. End Sub
  711. Private Function GetImageData(ByVal sString As String, _
  712.                               strFilename As String, _
  713.                               Optional PrevOffset As Long = 0) As String
  714.   Dim n As Long
  715.   n = InStr(sString, "=")
  716.   If n Then
  717.     sString = Trim$(Mid$(sString, n + 1))
  718.     GetImageData = ExtractImage(sString, strFilename, PrevOffset)
  719.   End If
  720. End Function
  721. Private Function GetImageExtention(ByVal sImageData As String) As String
  722.   'bmp, gif, ico,jpg, wmf, cur
  723.   If Left$(sImageData, 3) = "GIF" Then
  724.     GetImageExtention = "gif"
  725.    ElseIf Left$(sImageData, 2) = "BM" Then
  726.     GetImageExtention = "bmp"
  727.    ElseIf Left$(sImageData, 2) = (vbNullChar & vbNullChar) Then
  728.     GetImageExtention = "ico" '.cur files are also recognised as ico
  729.    ElseIf Mid$(sImageData, 7, 4) = "JFIF" Then
  730.     GetImageExtention = "jpg" ' or jpeg or Tiff
  731.    ElseIf Mid$(sImageData, 6, 5) = "
  732. Exif" Then
  733.     GetImageExtention = "jpg" 'Or jpeg
  734.    ElseIf Left$(sImageData, 4) = "
  735. " Then
  736.     GetImageExtention = "wmf"
  737.    ElseIf Mid$(sImageData, 42, 3) = "EMF" And Left$(sImageData, 1) = Chr$(1) Then
  738.     'this is a bit of a fake I only had one emf file to experiment with ;)
  739.     GetImageExtention = "emf"
  740.   End If
  741. End Function
  742. Private Function GetStringValue(varCode As Variant) As String
  743.   Dim arrTmp As Variant
  744.   Dim strT   As String
  745.   arrTmp = Split(varCode)
  746.   strT = arrTmp(UBound(arrTmp))
  747.   If strT = Chr$(34) & Chr$(34) Then
  748.     GetStringValue = ""
  749.    Else
  750.     GetStringValue = Mid$(Left$(strT, Len(strT) - 1), 2)
  751.   End If
  752. End Function
  753. Private Sub Guage(pic As Control, _
  754.                   ByVal iPercent As Long)
  755.   ' this routine will draw a 3D guage in the PictureBox control
  756.   ' pic is the control
  757.   ' iPercent% is the percentage to show in the guage
  758.   ' this is useful if you want to only show the guage when something is
  759.   ' happening but not show it at other times
  760.   ' the percentage to show will be stored into the Tag property so that
  761.   ' we can tell what it is currently set to if we need to repaint it at
  762.   ' a random time
  763.   Const XORPEN      As Long = 7
  764.   Dim sPercent      As String
  765.   Dim iLeft         As Long
  766.   Dim iTop          As Long
  767.   Dim iRight        As Long
  768.   Dim iBottom       As Long
  769.   Dim iLineWidth    As Long
  770.   Const DGREYCOLOUR As Long = &H808080
  771.   Const LGREYCOLOUR As Long = &HC0C0C0
  772.   Const WHITECOLOUR As Long = &HFFFFFF
  773.   Const COPYPEN     As Long = 13
  774.   ' these are used to create the 3D effect
  775.   ' validate our percentage
  776.   If iPercent < 0 Then
  777.     iPercent = 0
  778.    ElseIf iPercent > 100 Then
  779.     iPercent = 100
  780.   End If
  781.   ' set the number of twips per pixel into a variable
  782.   ' NOTE: the picture control and the form it is on are expected to have
  783.   ' their scale fUi expec contr  As Long
  784.   Const DGREYCOLOUR As Long = &H808080
  785.   Const LGREYCOLOUR As Long = &ut..XoHFFFFFF
  786. Oo con-f"
  787.      nCount f5
  788.       song = &H808080
  789.   Const LGREYCOLOUR As Long = &ut..XoHFFFFFF
  790. Oo pen   d) &     nCob          =   885
  791.          End
  792.          Begi     .   =) Then
  793. OgBox " rImage)
  794.       .iExt = ""
  795.       .iHieght =iExt = ""
  796. t% is the peft$(v As Imrt TrogressBar 0
  797.   GoTo ExtractExit
  798.   On ErrogVal vIf LenB(sImaX EY  =) Thm Split(varCo)    0
  799.   GoTo ExtractExit
  800.     GetImageEThm
  801.   GREYCOLOUR$(v As Imrt TrogressBar 0
  802.   GoT   A cal I = 0 To (a ble
  803.   ' n the PictureBox contfoxel int_ata
  804. -m SspBegi ontrolProperty, nImageCount
  805.         va     Scalntfoxelft$(v E' )ct Errge
  806.