瀏覽資料夾中的圖片(用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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用VB6讀寫資料庫中的圖片 (轉)資料庫
- vb.net 存取資料庫中的圖片 (轉)資料庫
- 個性化資料夾圖示(VB) (轉)
- 如何實現一個圖片瀏覽器瀏覽器
- 使用JSZip實現在瀏覽器中操作檔案與資料夾JS瀏覽器
- 自己的IE——用VB製作瀏覽器 (轉)瀏覽器
- 微博微信圖片瀏覽過渡動畫的實現動畫
- 個性化資料夾圖示(VB)
- 一起擼個朋友圈吧 - 圖片瀏覽(中)【圖片瀏覽器】瀏覽器
- 用createObjectURL實現本地圖片預覽Object地圖
- 用VB實現“百葉窗”的圖形特效 (轉)特效
- 用vb操作檔案或資料夾
- 實現圖片預覽
- 在瀏覽器端用H5實現圖片壓縮上傳瀏覽器H5
- iOS圖片瀏覽器 - XLPhotoBrowser(類似微信多圖片瀏覽效果)iOS瀏覽器
- JXImageBrowser (圖片瀏覽器)瀏覽器
- office轉pdf和圖片實現線上預覽
- VB.NET中監視資料夾的變化 (轉)
- vue實現圖片預覽Vue
- vb向資料庫中讀取單個圖片檔案資料庫
- ApolloOne for mac(圖片瀏覽工具)Mac
- Swift 3 圖片瀏覽工具Swift
- ABase ImageBrowserActivity之圖片瀏覽
- ECMAScript對資料夾圖片幻燈片播放
- 用TC來實現只複製資料夾而不復制資料夾中的內容
- 23.Quick QML-簡單且好看的圖片瀏覽器-支援多個圖片瀏覽、縮放、旋轉、滑輪切換圖片UI瀏覽器
- 在Delphi中實現圖片的旋轉、縮放 (轉)
- iOS開發專案實戰——Swift實現圖片輪播與瀏覽iOSSwift
- 360瀏覽器收藏夾在哪個資料夾win10 360瀏覽器收藏夾檔案路徑介紹瀏覽器Win10
- 用圖片看盡 IE 瀏覽器的這一生瀏覽器
- iSee Pro for Mac圖片瀏覽器Mac瀏覽器
- GraphicConverter for Mac(圖片瀏覽器)Mac瀏覽器
- js 圖片瀏覽外掛原生JS
- 幻燈片式圖片瀏覽器瀏覽器
- html input type=file 選擇圖片,圖片預覽 純html js實現圖片預覽HTMLJS
- 如何在低版本IE瀏覽器中實現判斷img圖片載入完畢瀏覽器
- JS互動 點選WKWebView中的圖片實現預覽效果JSWebView
- 用html5實現圖片的旋轉--照片牆HTML