Browse the image in the folder (with VB implementation) First, you want to create a new project, add the DirlistBox control, DriveStbox control, FileListBox control, ComboBox control, TextBox control, vscrollbar control, and a Command1 control in Form1, and enter the following code in the code box. :
Option expedition
private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Longprivate Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Longprivate Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Longprivate Const MAX_PATH = 260private Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd Typeprivate Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cfilename as string * max_path calternate as string * 14nd Type
Dim Pic As ObjectPrivate Sub Command1_Click () Dim obj As ObjectDim pcname As StringDim i As Long, j As Long, counter As LongDim wfd As WIN32_FIND_DATADim source As String, piname As StringDim hfile As LongDim nfile As LongDim filename () As StringDim x As Long Length1 as long, width1 as longcounter = 0set pic = form1.controls.add ("vb.picturebox", "test") PIC.Visible = Trueif Right (Dir1.Path, 1) <> "/" THEN SOURCE = DIR1 .Path & "/" & Text1.TextElse source = Dir1.Path & Text1.TextEnd Ifhfile = FindFirstFile (source, wfd) If hfile = -1 Then MsgBox "file not found" End Ifcounter = counter 1Donfile = FindNextFile (hfile, wfd) If nfile <> 0 Thencounter = counter 1End IfLoop Until nfile = 0ReDim filename (counter) As Stringhfile = FindFirstFile (source, wfd) filename (0) = wfd.cFileNameFor i = 1 To counter nfile = hfile FindNextFile (, wfd FILENAME (I) = wfd.cfilenamenext Iif Right (Dir1.Path, 1) <> "/" Thensource = Dir1.Path & "ElSesource = Dir1.Pathend ifcall FindClose (HFile)
For i = 0 to (counter / 4) for j = 0 to 3piname = "Picture" & J 1 i * 4set Obj = form1.controls.add ("vb.image" Obj.width = 1500obj. Height = 1500obj.stretch = trueSet obj.container = picobj.Left = j * obj.widthobj.top = i * obj.Heightif (j 1 i * 4)> counter, linend ifobj.picture = loadingPicture (Source & (Source & (Source & FILENAME (J 1 I * 4)))) Obj.visible = truenext jnext = j * Obj.widthLength1 = i * obj.HeightPic.Width = 4 * Obj.widthPic.Height = length1pic.left = DIR1. Left Dir1.WidthPic.Top = 0width1 = 4 * obj.Widthlength1 = i * obj.HeightVScroll1.Min = 0VScroll1.Max = 32767End SubPrivate Sub Dir1_Change () File1.filename = Dir1.PathEnd SubPrivate Sub Drive1_Change () Dir1.Path = Drive1.DriveEnd SubPrivate Sub Form_Load () Combo1.Text = "* .jpg" Combo1.AddItem "* .bmp" Combo1.AddItem "* .gif" VScroll1.LargeChange = 200VScroll1.SmallChange = 50Text1.Text = Combo1.TextEnd SubPrivate Sub Vscroll1_change () pic.top = 0 - vscroll1.valueEnd Sub This program is debugged in the VB6.0 WinME environment. Welcome readers and I am discussing. My email is: ywchen2000@etang.com