home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / Thumbnail Image Browser / Thumbs.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-02-12  |  24.2 KB  |  632 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmThumbs 
  4.    Caption         =   "Thumb View"
  5.    ClientHeight    =   3420
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4320
  9.    Icon            =   "Thumbs.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    ScaleHeight     =   228
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   288
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.PictureBox picProgress 
  17.       AutoRedraw      =   -1  'True
  18.       Height          =   270
  19.       Left            =   3225
  20.       ScaleHeight     =   14
  21.       ScaleMode       =   3  'Pixel
  22.       ScaleWidth      =   56
  23.       TabIndex        =   11
  24.       Top             =   2685
  25.       Width           =   900
  26.       Begin VB.PictureBox picProgressSlide 
  27.          Appearance      =   0  'Flat
  28.          AutoRedraw      =   -1  'True
  29.          BackColor       =   &H8000000D&
  30.          BorderStyle     =   0  'None
  31.          ForeColor       =   &H80000008&
  32.          Height          =   210
  33.          Left            =   0
  34.          ScaleHeight     =   14
  35.          ScaleMode       =   3  'Pixel
  36.          ScaleWidth      =   17
  37.          TabIndex        =   12
  38.          Top             =   0
  39.          Width           =   255
  40.       End
  41.    End
  42.    Begin MSComctlLib.StatusBar sbrMain 
  43.       Align           =   2  'Align Bottom
  44.       Height          =   315
  45.       Left            =   0
  46.       TabIndex        =   8
  47.       Top             =   3105
  48.       Width           =   4320
  49.       _ExtentX        =   7620
  50.       _ExtentY        =   556
  51.       _Version        =   393216
  52.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  53.          NumPanels       =   2
  54.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  55.             Bevel           =   0
  56.             Enabled         =   0   'False
  57.             Object.Width           =   529
  58.             MinWidth        =   529
  59.             Picture         =   "Thumbs.frx":1042
  60.          EndProperty
  61.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  62.             AutoSize        =   1
  63.             Object.Width           =   6641
  64.          EndProperty
  65.       EndProperty
  66.    End
  67.    Begin VB.PictureBox picThumb 
  68.       Appearance      =   0  'Flat
  69.       AutoRedraw      =   -1  'True
  70.       AutoSize        =   -1  'True
  71.       BackColor       =   &H80000005&
  72.       BorderStyle     =   0  'None
  73.       ForeColor       =   &H80000008&
  74.       Height          =   960
  75.       Left            =   2175
  76.       ScaleHeight     =   64
  77.       ScaleMode       =   3  'Pixel
  78.       ScaleWidth      =   64
  79.       TabIndex        =   4
  80.       Top             =   1995
  81.       Visible         =   0   'False
  82.       Width           =   960
  83.    End
  84.    Begin VB.FileListBox filHidden 
  85.       Height          =   480
  86.       Left            =   3225
  87.       Pattern         =   "*.bmp;*.dib;*.rle;*.gif;*.jpg;*.wmf;*.emf;*.ico;*.cur"
  88.       TabIndex        =   7
  89.       Top             =   2130
  90.       Visible         =   0   'False
  91.       Width           =   915
  92.    End
  93.    Begin MSComctlLib.ImageList imlTools 
  94.       Left            =   3555
  95.       Top             =   780
  96.       _ExtentX        =   1005
  97.       _ExtentY        =   1005
  98.       BackColor       =   -2147483643
  99.       ImageWidth      =   16
  100.       ImageHeight     =   16
  101.       MaskColor       =   12632256
  102.       _Version        =   393216
  103.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  104.          NumListImages   =   4
  105.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  106.             Picture         =   "Thumbs.frx":13DE
  107.             Key             =   "Browse"
  108.          EndProperty
  109.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  110.             Picture         =   "Thumbs.frx":177A
  111.             Key             =   "Edit"
  112.          EndProperty
  113.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  114.             Picture         =   "Thumbs.frx":1B16
  115.             Key             =   "Exit"
  116.          EndProperty
  117.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  118.             Picture         =   "Thumbs.frx":1EB2
  119.             Key             =   "Refresh"
  120.          EndProperty
  121.       EndProperty
  122.    End
  123.    Begin MSComctlLib.Toolbar tbrMain 
  124.       Align           =   1  'Align Top
  125.       Height          =   570
  126.       Left            =   0
  127.       TabIndex        =   6
  128.       Top             =   0
  129.       Width           =   4320
  130.       _ExtentX        =   7620
  131.       _ExtentY        =   1005
  132.       ButtonWidth     =   1323
  133.       ButtonHeight    =   953
  134.       Appearance      =   1
  135.       Style           =   1
  136.       ImageList       =   "imlTools"
  137.       HotImageList    =   "imlToolsHover"
  138.       _Version        =   393216
  139.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  140.          NumButtons      =   8
  141.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  142.             Style           =   3
  143.          EndProperty
  144.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  145.             Caption         =   "&Browse"
  146.             Key             =   "Browse"
  147.             Object.ToolTipText     =   "Select a Folder"
  148.             ImageKey        =   "Browse"
  149.          EndProperty
  150.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  151.             Style           =   3
  152.          EndProperty
  153.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  154.             Caption         =   "&Edit"
  155.             Key             =   "Edit"
  156.             Object.ToolTipText     =   "Open selected image in an Editor"
  157.             ImageKey        =   "Edit"
  158.          EndProperty
  159.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  160.             Caption         =   "&Refresh"
  161.             Key             =   "Refresh"
  162.             Object.ToolTipText     =   "Refresh Thumbnails"
  163.             ImageKey        =   "Refresh"
  164.          EndProperty
  165.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  166.             Style           =   3
  167.          EndProperty
  168.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  169.             Caption         =   "E&xit"
  170.             Key             =   "Exit"
  171.             Object.ToolTipText     =   "Exit Program"
  172.             ImageKey        =   "Exit"
  173.          EndProperty
  174.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  175.             Style           =   3
  176.          EndProperty
  177.       EndProperty
  178.       Begin VB.PictureBox picCount 
  179.          Appearance      =   0  'Flat
  180.          BorderStyle     =   0  'None
  181.          ForeColor       =   &H80000008&
  182.          Height          =   285
  183.          Left            =   3600
  184.          ScaleHeight     =   285
  185.          ScaleWidth      =   1815
  186.          TabIndex        =   9
  187.          Top             =   135
  188.          Width           =   1815
  189.          Begin VB.Label lblCount 
  190.             AutoSize        =   -1  'True
  191.             BackStyle       =   0  'Transparent
  192.             Caption         =   "lblCount"
  193.             Height          =   195
  194.             Left            =   0
  195.             TabIndex        =   10
  196.             Top             =   45
  197.             Width           =   570
  198.          End
  199.       End
  200.    End
  201.    Begin VB.PictureBox picLoad 
  202.       Appearance      =   0  'Flat
  203.       AutoRedraw      =   -1  'True
  204.       AutoSize        =   -1  'True
  205.       BackColor       =   &H80000005&
  206.       BorderStyle     =   0  'None
  207.       ForeColor       =   &H80000008&
  208.       Height          =   1200
  209.       Left            =   2175
  210.       ScaleHeight     =   80
  211.       ScaleMode       =   3  'Pixel
  212.       ScaleWidth      =   80
  213.       TabIndex        =   3
  214.       Top             =   765
  215.       Visible         =   0   'False
  216.       Width           =   1200
  217.    End
  218.    Begin VB.PictureBox picFrame 
  219.       Height          =   2160
  220.       Left            =   45
  221.       ScaleHeight     =   140
  222.       ScaleMode       =   3  'Pixel
  223.       ScaleWidth      =   131
  224.       TabIndex        =   0
  225.       Top             =   780
  226.       Width           =   2025
  227.       Begin VB.PictureBox picSlide 
  228.          Appearance      =   0  'Flat
  229.          BackColor       =   &H80000005&
  230.          BorderStyle     =   0  'None
  231.          ForeColor       =   &H80000008&
  232.          Height          =   1695
  233.          Left            =   90
  234.          ScaleHeight     =   113
  235.          ScaleMode       =   3  'Pixel
  236.          ScaleWidth      =   104
  237.          TabIndex        =   2
  238.          Top             =   90
  239.          Width           =   1560
  240.          Begin VB.OptionButton optThumb 
  241.             Height          =   1440
  242.             Index           =   0
  243.             Left            =   60
  244.             Style           =   1  'Graphical
  245.             TabIndex        =   5
  246.             Top             =   60
  247.             Width           =   1200
  248.          End
  249.       End
  250.       Begin VB.VScrollBar vsbSlide 
  251.          Height          =   2100
  252.          Left            =   1755
  253.          TabIndex        =   1
  254.          Top             =   0
  255.          Width           =   210
  256.       End
  257.    End
  258.    Begin MSComctlLib.ImageList imlToolsHover 
  259.       Left            =   3555
  260.       Top             =   1395
  261.       _ExtentX        =   1005
  262.       _ExtentY        =   1005
  263.       BackColor       =   -2147483643
  264.       ImageWidth      =   16
  265.       ImageHeight     =   16
  266.       MaskColor       =   12632256
  267.       _Version        =   393216
  268.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  269.          NumListImages   =   4
  270.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  271.             Picture         =   "Thumbs.frx":224E
  272.             Key             =   "Browse"
  273.          EndProperty
  274.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  275.             Picture         =   "Thumbs.frx":25EA
  276.             Key             =   "Edit"
  277.          EndProperty
  278.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  279.             Picture         =   "Thumbs.frx":2986
  280.             Key             =   "Exit"
  281.          EndProperty
  282.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  283.             Picture         =   "Thumbs.frx":2D22
  284.             Key             =   "Refresh"
  285.          EndProperty
  286.       EndProperty
  287.    End
  288. Attribute VB_Name = "frmThumbs"
  289. Attribute VB_GlobalNameSpace = False
  290. Attribute VB_Creatable = False
  291. Attribute VB_PredeclaredId = True
  292. Attribute VB_Exposed = False
  293. Option Explicit
  294. Private Type PointAPI
  295.     X  As Long
  296.     Y  As Long
  297. End Type
  298. Private mbActive                As Boolean
  299. Private mlCurThumb              As Long
  300. Private Const SRCCOPY           As Long = &HCC0020
  301. Private Const STRETCH_HALFTONE  As Long = &H4&
  302. Private Const SW_RESTORE        As Long = &H9&
  303. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  304. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  305. Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
  306. Private Declare Function SetBrushOrgEx Lib "gdi32" (ByVal hDC As Long, ByVal nXOrg As Long, ByVal nYOrg As Long, lpPt As PointAPI) As Long
  307. Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hDC As Long, ByVal nStretchMode As Long) As Long
  308. Private Declare Function StretchBlt Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
  309. Private Declare Function UnrealizeObject Lib "gdi32" (ByVal hObject As Long) As Long
  310. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  311. Private Sub Browse(Optional ByVal bDontShowBrowser As Boolean)
  312. Dim lRet    As Long
  313. Dim sPath   As String
  314.     sPath = GetInitEntry("Main", "Last Path", "C:\")
  315.     If Not bDontShowBrowser Then
  316.         sPath = BrowseForFolder(Me.hWnd, "Select a Folder with Images...", sPath)
  317.     End If
  318.     If Len(sPath) > 0 Then
  319.         On Error Resume Next
  320.         filHidden.Path = sPath
  321.         If Err.Number = 0 Then
  322.             CreateThumbs
  323.             lRet = SetInitEntry("Main", "Last Path", sPath)
  324.         End If
  325.     End If
  326.             
  327. End Sub
  328. Private Sub CreateThumbPic(picSource As PictureBox, picThumb As PictureBox)
  329. 'This sub uses the halftone stretch mode, which produces the highest
  330. 'quality possible, when stretching the bitmap.
  331. Dim lRet            As Long
  332. Dim lLeft           As Long
  333. Dim lTop            As Long
  334. Dim lWidth          As Long
  335. Dim lHeight         As Long
  336. Dim lForeColor      As Long
  337. Dim hBrush          As Long
  338. Dim hDummyBrush     As Long
  339. Dim lOrigMode       As Long
  340. Dim fScale          As Single
  341. Dim uBrushOrigPt    As PointAPI
  342.     picThumb.Width = 64
  343.     picThumb.Height = 64
  344.     picThumb.BackColor = vbButtonFace
  345.     picThumb.AutoRedraw = True
  346.     picThumb.Cls
  347.     If picSource.Width <= picThumb.Width - 2 And picSource.Height <= picThumb.Height - 2 Then
  348.         fScale = 1
  349.     Else
  350.         fScale = IIf(picSource.Width > picSource.Height, (picThumb.Width - 2) / picSource.Width, (picThumb.Height - 2) / picSource.Height)
  351.     End If
  352.     lWidth = picSource.Width * fScale
  353.     lHeight = picSource.Height * fScale
  354.     lLeft = Int((picThumb.Width - lWidth) / 2)
  355.     lTop = Int((picThumb.Height - lHeight) / 2)
  356.     'Store the original ForeColor
  357.     lForeColor = picThumb.ForeColor
  358.     'Set picEdit's stretch mode to halftone (this may cause misalignment of the brush)
  359.     lOrigMode = SetStretchBltMode(picThumb.hDC, STRETCH_HALFTONE)
  360.     'Realign the brush...
  361.     'Get picEdit's brush by selecting a dummy brush into the DC
  362.     hDummyBrush = CreateSolidBrush(lForeColor)
  363.     hBrush = SelectObject(picThumb.hDC, hDummyBrush)
  364.     'Reset the brush (This will force windows to realign it when it's put back)
  365.     lRet = UnrealizeObject(hBrush)
  366.     'Set picEdit's brush alignment coordinates to the left-top of the bitmap
  367.     lRet = SetBrushOrgEx(picThumb.hDC, lLeft, lTop, uBrushOrigPt)
  368.     'Now put the original brush back into the DC at the new alignment
  369.     hDummyBrush = SelectObject(picThumb.hDC, hBrush)
  370.     'Stretch the bitmap
  371.     lRet = StretchBlt(picThumb.hDC, lLeft, lTop, lWidth, lHeight, _
  372.             picSource.hDC, 0, 0, picSource.Width, picSource.Height, SRCCOPY)
  373.     'Set the stretch mode back to it's original mode
  374.     lRet = SetStretchBltMode(picThumb.hDC, lOrigMode)
  375.     'Reset the original alignment of the brush...
  376.     'Get picEdit's brush by selecting the dummy brush back into the DC
  377.     hBrush = SelectObject(picThumb.hDC, hDummyBrush)
  378.     'Reset the brush (This will force windows to realign it when it's put back)
  379.     lRet = UnrealizeObject(hBrush)
  380.     'Set the brush alignment back to the original coordinates
  381.     lRet = SetBrushOrgEx(picThumb.hDC, uBrushOrigPt.X, uBrushOrigPt.Y, uBrushOrigPt)
  382.     'Now put the original brush back into picEdit's DC at the original alignment
  383.     hDummyBrush = SelectObject(picThumb.hDC, hBrush)
  384.     'Get rid of the dummy brush
  385.     lRet = DeleteObject(hDummyBrush)
  386.     'Restore the original ForeColor
  387.     picThumb.ForeColor = lForeColor
  388.     picThumb.Line (lLeft - 1, lTop - 1)-Step(lWidth + 1, lHeight + 1), &H0&, B
  389. End Sub
  390. Private Sub CreateThumbs()
  391. Dim iMaxLen As Integer
  392. Dim X       As Long
  393. Dim Y       As Long
  394. Dim lIdx    As Long
  395. Dim lPicCnt As Long
  396. Dim lFilCnt As Long
  397. Dim sPath   As String
  398. Dim sText   As String
  399.     Screen.MousePointer = vbHourglass
  400.     filHidden.Refresh
  401.     picSlide.Move 0, 0, optThumb(0).Width, optThumb(0).Height
  402.     picSlide.Visible = False
  403.     picSlide.BackColor = vbButtonFace
  404.     Set picSlide.Font = optThumb(0).Font
  405.     While optThumb.Count > 1
  406.         Unload optThumb(optThumb.Count - 1)
  407.     Wend
  408.     DoEvents
  409.     On Error Resume Next
  410.     sPath = filHidden.Path
  411.     sPath = sPath & IIf(Right$(sPath, 1) <> "\", "\", "")
  412.     lFilCnt = filHidden.ListCount
  413.     lblCount.Caption = "Images: " & Format$(lFilCnt, "#,##0")
  414.     If Len(sPath) > 0 Then
  415.         Call StartProgress
  416.         For lIdx = 0 To filHidden.ListCount - 1
  417.             Call UpdateProgress((CSng(lIdx + 1) / CSng(lFilCnt)) * 100, filHidden.List(lIdx))
  418.             Set picLoad.Picture = LoadPicture()
  419.             picLoad.Cls
  420.             Err.Clear
  421.             If InStr(1, LCase$(filHidden.List(lIdx)), ".ico") > 0 _
  422.               Or InStr(1, LCase$(filHidden.List(lIdx)), ".cur") > 0 Then
  423.                 Set picLoad.Picture = LoadPicture(sPath & filHidden.List(lIdx), vbLPLargeShell, vbLPDefault)
  424.             Else
  425.                 Set picLoad.Picture = LoadPicture(sPath & filHidden.List(lIdx))
  426.             End If
  427.             If Err.Number = 0 Then
  428.                 Call CreateThumbPic(picLoad, picThumb)
  429.                 If lPicCnt > 0 Then
  430.                     Load optThumb(lPicCnt)
  431.                     Set optThumb(lPicCnt).Container = picSlide
  432.                 End If
  433.                 optThumb(lPicCnt).Tag = filHidden.List(lIdx)
  434.                 Set optThumb(lPicCnt).Picture = picThumb.Image
  435.                 sText = filHidden.List(lIdx)
  436.                 iMaxLen = optThumb(lPicCnt).Width - 15
  437.                 If picSlide.TextWidth(sText) > iMaxLen Then
  438.                     iMaxLen = iMaxLen - picSlide.TextWidth("...")
  439.                 End If
  440.                 While picSlide.TextWidth(sText) > iMaxLen
  441.                     sText = Left$(sText, Len(sText) - 1)
  442.                 Wend
  443.                 If iMaxLen < optThumb(lPicCnt).Width - 15 Then
  444.                     sText = sText & "..."
  445.                 End If
  446.                 optThumb(lPicCnt).Caption = sText
  447.                 optThumb(lPicCnt).Visible = True
  448.                 lPicCnt = lPicCnt + 1
  449.             End If
  450.         Next lIdx
  451.         
  452.         picProgress.Visible = False
  453.         
  454.         'Free the unneeded resources
  455.         Set picLoad.Picture = LoadPicture()
  456.         Set picThumb.Picture = LoadPicture()
  457.         optThumb(0).Value = True
  458.         mlCurThumb = 0
  459.         Call Form_Resize
  460.         picSlide.Visible = True
  461.         lblCount.Caption = "Images: " & Format$(lPicCnt, "#,##0")
  462.         
  463.     End If
  464.     Screen.MousePointer = vbDefault
  465. End Sub
  466. Private Sub Edit()
  467. Dim lRet    As Long
  468. Dim sFile   As String
  469.     sFile = filHidden.Path
  470.     If Len(sFile) > 0 Then
  471.         sFile = sFile & IIf(Right$(sFile, 1) <> "\", "\", "")
  472.         sFile = sFile & optThumb(mlCurThumb).Tag
  473.         lRet = ShellExecute(Me.hWnd, "Open", sFile, &H0&, &H0&, SW_RESTORE)
  474.     End If
  475. End Sub
  476. Private Sub StartProgress()
  477.     With picProgress
  478.         .Cls
  479.         .BackColor = vbButtonFace
  480.         .ForeColor = vbButtonText
  481.         .Move sbrMain.Left + sbrMain.Panels(2).Left, sbrMain.Top + 1, _
  482.             sbrMain.Panels(2).Width, sbrMain.Height - 1
  483.     End With
  484.     With picProgressSlide
  485.         .Cls
  486.         .BackColor = vbHighlight
  487.         .ForeColor = vbHighlightText
  488.         .Move 0, 0, 1, picProgress.ScaleHeight
  489.     End With
  490.     picProgress.Visible = True
  491. End Sub
  492. Private Sub UpdateProgress(ByVal iPercent As Integer, ByVal sCaption As String)
  493. Dim lTextTop    As Long
  494.     picProgress.Cls
  495.     picProgressSlide.Cls
  496.     picProgressSlide.Width = picProgress.ScaleWidth * (CSng(iPercent) / 100!)
  497.     lTextTop = (picProgress.ScaleHeight - picProgress.TextHeight(sCaption)) / 2
  498.     picProgress.CurrentX = 3
  499.     picProgress.CurrentY = lTextTop
  500.     picProgress.Print sCaption
  501.     picProgressSlide.CurrentX = 3
  502.     picProgressSlide.CurrentY = lTextTop
  503.     picProgressSlide.Print sCaption
  504.     DoEvents
  505. End Sub
  506. Private Sub filHidden_PathChange()
  507. Dim sPath As String
  508.     sPath = filHidden.Path
  509.     If Len(sPath) > 0 Then
  510.         sPath = sPath & IIf(Right$(sPath, 1) <> "\", "\", "")
  511.     End If
  512.     sbrMain.Panels(2).Text = sPath
  513.     lblCount.Caption = "Images: 0"
  514. End Sub
  515. Private Sub Form_Activate()
  516.     If Not mbActive Then
  517.         picSlide.Visible = False
  518.         DoEvents
  519.         mbActive = True
  520.         Call Browse(True)
  521.     End If
  522.         
  523. End Sub
  524. Private Sub Form_Load()
  525. Dim sPos    As String
  526. Dim saPos() As String
  527. Dim laPos() As Long
  528.     'Get the window position
  529.     sPos = GetInitEntry("Main", "Window Position", sPos)
  530.     If Len(sPos) > 0 Then
  531.         saPos = Split(sPos, ", ")
  532.     End If
  533.     'Just in case saPos() is Empty
  534.     ReDim Preserve saPos(3)
  535.     ReDim laPos(3)
  536.     laPos(0) = IIf(Len(saPos(0)) = 0, Me.Left, Val(Trim$(saPos(0))))
  537.     laPos(1) = IIf(Len(saPos(1)) = 0, Me.Top, Val(Trim$(saPos(1))))
  538.     laPos(2) = IIf(Len(saPos(2)) = 0, Me.Width, Val(Trim$(saPos(2))))
  539.     laPos(3) = IIf(Len(saPos(3)) = 0, Me.Height, Val(Trim$(saPos(3))))
  540.     Me.Move laPos(0), laPos(1), laPos(2), laPos(3)
  541.     If CBool(GetInitEntry("Main", "Maximized", CStr(False))) Then
  542.         Me.WindowState = vbMaximized
  543.     End If
  544. End Sub
  545. Private Sub Form_Resize()
  546. Dim X       As Long
  547. Dim Y       As Long
  548. Dim lIdx    As Long
  549. Dim lCols   As Long
  550.         
  551.     If Me.WindowState <> vbMinimized Then
  552.         If Me.Width < 346 * Screen.TwipsPerPixelX Then
  553.             Me.Width = 346 * Screen.TwipsPerPixelX
  554.         ElseIf Me.Height < 378 * Screen.TwipsPerPixelY Then
  555.             Me.Height = 378 * Screen.TwipsPerPixelY
  556.         Else
  557.             picFrame.Move 0, tbrMain.Height, Me.ScaleWidth, Me.ScaleHeight - tbrMain.Height - sbrMain.Height
  558.             vsbSlide.Move picFrame.ScaleWidth - vsbSlide.Width, 0, vsbSlide.Width, picFrame.ScaleHeight
  559.             lCols = Int((picFrame.ScaleWidth - vsbSlide.Width) / optThumb(0).Width)
  560.             For lIdx = 0 To optThumb.Count - 1
  561.                 X = (lIdx Mod lCols) * optThumb(0).Width
  562.                 Y = Int(lIdx / lCols) * optThumb(0).Height
  563.                 optThumb(lIdx).Move X, Y
  564.             Next lIdx
  565.             picSlide.Width = lCols * optThumb(0).Width
  566.             picSlide.Height = Int(optThumb.Count / lCols) * optThumb(0).Height
  567.             If Int(optThumb.Count / lCols) < (optThumb.Count / lCols) Then
  568.                 picSlide.Height = picSlide.Height + optThumb(0).Height
  569.             End If
  570.             vsbSlide.Value = 0
  571.             vsbSlide.Max = picSlide.Height - picFrame.ScaleHeight
  572.             If vsbSlide.Max < 0 Then
  573.                 vsbSlide.Max = 0
  574.                 vsbSlide.Enabled = False
  575.             Else
  576.                 vsbSlide.Enabled = True
  577.                 vsbSlide.SmallChange = optThumb(0).Height
  578.                 vsbSlide.LargeChange = picFrame.ScaleHeight
  579.             End If
  580.         End If
  581.     End If
  582. End Sub
  583. Private Sub Form_Unload(Cancel As Integer)
  584. Dim lIdx As Long
  585. Dim lRet As Long
  586. Dim sPos As String
  587.     For lIdx = 1 To optThumb.Count - 1
  588.         Unload optThumb(lIdx)
  589.     Next lIdx
  590.     If Me.WindowState = vbNormal Then
  591.         sPos = CStr(Me.Left) & ", " & CStr(Me.Top) & ", " & CStr(Me.Width) & ", " & CStr(Me.Height)
  592.         lRet = SetInitEntry("Main", "Window Position", sPos)
  593.     End If
  594.     lRet = SetInitEntry("Main", "Maximized", CStr(Me.WindowState = vbMaximized))
  595. End Sub
  596. Private Sub optThumb_Click(Index As Integer)
  597. Dim sPath As String
  598.     sPath = filHidden.Path
  599.     If Len(sPath) > 0 Then
  600.         sPath = sPath & IIf(Right$(sPath, 1) <> "\", "\", "")
  601.     End If
  602.     sbrMain.Panels(2).Text = sPath & optThumb(Index).Tag
  603.     mlCurThumb = Index
  604. End Sub
  605. Private Sub optThumb_DblClick(Index As Integer)
  606.     Call tbrMain_ButtonClick(tbrMain.Buttons("Edit"))
  607. End Sub
  608. Private Sub tbrMain_ButtonClick(ByVal Button As MSComctlLib.Button)
  609.     Select Case Button.Key
  610.         Case "Browse"
  611.             Call Browse
  612.             
  613.         Case "Edit"
  614.             Call Edit
  615.             
  616.         Case "Refresh"
  617.             Call CreateThumbs
  618.             
  619.         Case "Exit"
  620.             Unload Me
  621.             End
  622.             
  623.     End Select
  624. End Sub
  625. Private Sub vsbSlide_Change()
  626.     picSlide.Top = -vsbSlide.Value
  627.     picFrame.SetFocus
  628. End Sub
  629. Private Sub vsbSlide_Scroll()
  630.     vsbSlide_Change
  631. End Sub
  632.