瀏覽資料夾中的圖片(用VB實現) (轉)
瀏覽夾中的圖片(用VB實現)
首先要新建一個工程,在Form1中新增dirlistbox,drivelistbox控制元件,filelistbox控制元件,combobox控制元件,textbox控制元件,vscrollbar控制元件和一個command1控制元件
然後在程式碼框中輸入以下程式碼:
Option Explicit
private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As _FIND_DATA) As Long
private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
private Const MAX_PATH = 260
private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
private 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 * 14
End Type
Dim Pic As
Private Sub Command1_Click()
Dim obj As Object
Dim pcname As String
Dim i As Long, j As Long, counter As Long
Dim wfd As WIN32_FIND_DATA
Dim As String, piname As String
Dim hfile As Long
Dim nfile As Long
Dim filename() As String
Dim x As Long, length1 As Long, width1 As Long
counter = 0
Set Pic = Form1.Controls.Add("VB.PictureBox", "test")
Pic.Visible = True
If Right(Dir1.Path, 1) <> "" Then
source = Dir1.Path & "" & Text1.Text
Else
source = Dir1.Path & Text1.Text
End If
hfile = FindFirstFile(source, wfd)
If hfile = -1 Then
MsgBox "沒有找到檔案"
End If
counter = counter + 1
Do
nfile = FindNextFile(hfile, wfd)
If nfile <> 0 Then
counter = counter + 1
End If
L Until nfile = 0
ReDim filename(counter) As String
hfile = FindFirstFile(source, wfd)
filename(0) = wfd.cFileName
For i = 1 To counter
nfile = FindNextFile(hfile, wfd)
filename(i) = wfd.cFileName
Next i
If Right(Dir1.Path, 1) <> "" Then
source = Dir1.Path & ""
Else
source = Dir1.Path
End If
Call FindClose(hfile)
For i = 0 To (counter / 4)
For j = 0 To 3
piname = "picture" & j + 1 + i * 4
Set obj = Form1.Controls.Add("VB.Image", piname)
obj.Width = 1500
obj.Height = 1500
obj.Stretch = True
Set obj.Container = Pic
obj.Left = j * obj.Width
obj.Top = i * obj.Height
If (j + 1 + i * 4) > counter Then
GoTo line
End If
obj.Picture = LoadPicture(source & (filename(j + 1 + i * 4)))
obj.Visible = True
Next j
Next i
line:
width1 = j * obj.Width
length1 = i * obj.Height
Pic.Width = 4 * obj.Width
Pic.Height = length1
Pic.Left = Dir1.Left + Dir1.Width
Pic.Top = 0
width1 = 4 * obj.Width
length1 = i * obj.Height
VScroll1.Min = 0
VScroll1.Max = 32767
End Sub
Private Sub Dir1_Change()
File1.filename = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
Combo1.Text = "*.jpg"
Combo1.AddItem "*.bmp"
Combo1.AddItem "*.gif"
VScroll1.LargeChange = 200
VScroll1.SmallChange = 50
Text1.Text = Combo1.Text
End Sub
Private Sub VScroll1_Change()
Pic.Top = 0 - VScroll1.Value
End Sub
該在.0+環境下透過。
歡迎廣大讀者和本人討論。我的電子是:to:ywchen2000@etang.com">ywchen2000@etang.com
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-977286/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用JSZip實現在瀏覽器中操作檔案與資料夾JS瀏覽器
- 個性化資料夾圖示(VB)
- 用createObjectURL實現本地圖片預覽Object地圖
- 在瀏覽器端用H5實現圖片壓縮上傳瀏覽器H5
- 23.Quick QML-簡單且好看的圖片瀏覽器-支援多個圖片瀏覽、縮放、旋轉、滑輪切換圖片UI瀏覽器
- vue實現圖片預覽Vue
- GraphicConverter for Mac(圖片瀏覽器)Mac瀏覽器
- ApolloOne for mac(圖片瀏覽工具)Mac
- Qt實現圖片拖拽上傳過濾資料夾內圖片自動搜尋列表展示QT
- 360瀏覽器收藏夾在哪個資料夾win10 360瀏覽器收藏夾檔案路徑介紹瀏覽器Win10
- 用html5實現圖片的旋轉--照片牆HTML
- iSee Pro for Mac圖片瀏覽器Mac瀏覽器
- php實現pdf轉圖片PHP
- php實現圖片旋轉PHP
- html input type=file 選擇圖片,圖片預覽 純html js實現圖片預覽HTMLJS
- 前端實現圖片上傳預覽並轉換base64前端
- Laravel 自增瀏覽數實現(資料庫 + Redis)Laravel資料庫Redis
- 高效圖片瀏覽器:Pixea Plus for Mac瀏覽器Mac
- Mac圖片瀏覽軟體——XnViewMP for MacMacView
- FotoTime Mac(圖片瀏覽管理器)Mac
- 微信跳轉瀏覽器提示,微信瀏覽器中直接跳轉手機預設瀏覽器是怎麼實現的瀏覽器
- Typora 隱藏側邊欄圖片資料夾
- 瀏覽器 Web 訪問剪下板圖片瀏覽器Web
- Mac圖片編輯瀏覽工具:GraphicConverter 11Mac
- ApolloOne for Mac號稱最快的圖片瀏覽軟體Mac
- Java實現emf轉jpg png 圖片轉換Java
- @Summer 解決下Safari瀏覽器任意圖片預覽一片模糊的bug瀏覽器
- SpringMVC實現ajax上傳圖片實時預覽SpringMVC
- 精緻小巧的圖片瀏覽器:Viso for Mac v4.1.4啟用版瀏覽器Mac
- 利用百度AI OCR圖片識別,Java實現PDF中的圖片轉換成文字AIJava
- 用Python實現圖片的清晰掃描Python
- java+pgsql實現儲存圖片到資料庫,以及讀取資料庫儲存的圖片JavaSQL資料庫
- 如何利用 Chrome 瀏覽器實現滾動截圖Chrome瀏覽器
- Mac圖片編輯和瀏覽工具——GraphicConverter for MacMac
- 直播平臺原始碼,圖片放大瀏覽功能原始碼
- echarts圖表y軸資料反轉的實現Echarts
- 滑鼠懸浮圖片實現翻轉效果
- GO實現資料夾監控Go
- Java實現壓縮資料夾Java