| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1025 人关注过本帖
标题:求快速显示多张图片
取消只看楼主 加入收藏
PDCFNR
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2023-7-10
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
求快速显示多张图片
List1有数千张图片地址
For I = 0 To List1.ListCount - 1
                If CC1 Then
                    Exit For
                Else
                    Image1.Picture = LoadPicture(List1.List(I))
                End If
                Me.Caption = CStr(I + 1) & "/" & List1.ListCount
                DoEvents
            Next I
以上代码可执行,就是太慢。
搜索更多相关主题的帖子: For 显示 If 快速 图片 
2023-07-10 21:16
PDCFNR
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2023-7-10
收藏
得分:0 
回复 2楼 风吹过b
浏览图片,相当于看视频的效果。我相过预加载入内存,但太大了。
2023-07-10 21:31
PDCFNR
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2023-7-10
收藏
得分:0 
回复 4楼 风吹过b
谢谢您了!
测试过存入PropertyBag最多只能300张。
2023-07-10 22:05
PDCFNR
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2023-7-10
收藏
得分:0 
窗体一个Image,一个Lits。代码如下:
Option Explicit
Dim CC1 As Boolean

Private Sub Find1(MyPath As String)
    On Error Resume Next
    Dim Myname As String
    Dim dir_i() As String
    Dim I As Long
    Dim S As String
    Dim idir As Long
    If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
    Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
    Do While Myname <> ""
        If Myname <> "." And Myname <> ".." Then
            If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then
                idir = idir + 1
                ReDim Preserve dir_i(idir) As String
                dir_i(idir - 1) = Myname
            Else
                S = UCase$(Right$(Myname, Len(Myname) - InStrRev(Myname, ".")))
                If S = "JPG" Then List1.AddItem MyPath & Myname
                If List1.ListCount > 32760 Then Exit Sub
            End If
        End If
        Myname = Dir
        'DoEvents
    Loop
    For I = 0 To idir - 1
        Call Find1(MyPath + dir_i(I))
    Next I
    ReDim dir_i(0) As String
End Sub

Private Sub Form_Load()
    List1.Visible = False
    CC1 = True
End Sub

Private Sub Form_Resize()
    If Me.WindowState <> 1 Then
        Image1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
        List1.Move 0, 0
    End If
    Me.Caption = CStr(Me.ScaleWidth \ 10) & "x" & CStr(Me.ScaleHeight \ 10)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    CC1 = True
End Sub

Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim I As Integer
    If Button = 1 Then
        CC1 = Not CC1
        If List1.ListCount > 0 Then
            For I = 0 To List1.ListCount - 1
                If CC1 Then
                    Exit For
                Else
                    Image1.Picture = LoadPicture(List1.List(I))
                End If
                Me.Caption = CStr(I + 1) & "/" & List1.ListCount
                DoEvents
            Next I
        End If
        CC1 = True
    ElseIf Button = 2 Then
        List1.Visible = Not List1.Visible
    End If
End Sub

Private Sub Image1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
    Dim T1 As String
    Dim S As String
    Dim I As Integer
    For I = 1 To Data.Files.Count
        T1 = Data.Files(I)
        If (GetAttr(T1) And vbDirectory) = vbDirectory Then
            Find1 T1
        Else
            S = UCase$(Right$(T1, Len(T1) - InStrRev(T1, ".")))
            If S = "JPG" Then List1.AddItem T1
        End If
    Next
    Me.Caption = List1.ListCount
End Sub


Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
        CC1 = True
        List1.Clear
        Me.Caption = "0"
    End If
End Sub
2023-07-10 22:25
快速回复:求快速显示多张图片
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027777 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved