none
view SLIDESHOW of images of specific folder

    Question

  • I want vb6 code to display images of specific folder from Windows Picture and fax viewer using shimgvw.dll (Preview 1.0 Type Library).

    I can view single image using:

                                                        Preview1.ShowFile("aa.jpg")

    but what about slideshow of specific folder........??

    • Moved by Kee Poppy Thursday, January 13, 2011 2:57 AM (From:Visual Basic Language)
    Thursday, January 06, 2011 8:35 AM

All replies

  • Create a timer with the interval set to how often you want to change pictures. Use a loop to loop through all images in a folder...something like this:

     

    'Make sure you place this on the top line of your code
     Imports System.IO
    
    'This is the maximum number of images the slideshow will loop through
    Public SSImages(128) As String
    Public allowedExtensions() As String = {".jpg", ".png", ".gif", ".bmp"}
    Public CurrentImage As Integer = 0
    
    Private Sub getImgs(Dir As String, Extensions As String) 
      Dim di As New IO.DirectoryInfo(strDir)
      Dim aryFi As IO.FileInfo() = di.GetFiles()
      Dim fi As IO.FileInfo
      Dim I As Integer = 0
      For Each fi In aryFi
        If allowedExtensions.Contains(fi.Extension) Then
          SSImages(I) = fi.FullName
          I = I + 1
        End If
      Next
      ReDim SSImages(I)
    End Function
    
    
    'Place this into your timer  
    
    Preview1.ShowFile(SSImages(CurrentImage))
    If CurrentImage = SSImages.Count - 1 Then
      CurrentImage = 0
    Else
      CurrentImage = CurrentImage + 1
    End If
    

    Note: I just typed that out into the insert code window and have not tested it...should work though remember timer interval is in milliseconds (1000 = 1 second)

    Call it like this

    getImgs("C:\testdir")

    Timer1.Enabled = True

     

    You should add something there to see if getImgs actually finds images, maybe turn getImgs from a sub to a function and have it return true if it found any images, that way you dont start working with a blank array...but this should work as long as the folder contains images.

     

     


    Mike LaPointe LowLow Computers
    Friday, January 07, 2011 11:19 PM
  • WOW...i just noticed you said VB6 and you are in the wrong forum...

    Mike LaPointe LowLow Computers
    Friday, January 07, 2011 11:20 PM
  • Hi xxxyyyzzz123,

    Since your question is related to VB6, I would recommend you to read this link: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b

     

    Best Regards,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 10, 2011 7:44 AM