Jump to content

Display a list of images (As in an album)


Recommended Posts

Hello friends

I have a question regarding displaying a list of images.

What I want is to display a list of image thumbnails in a photo gallery/album. I have used listview control to display icons with texts. I want the same thing here. But just one little difference. I want the icons to be "bigger" (and not just icons).

When the user clicks on an image, a new window opens with the full view of the image. (The same thing that windows explorer does).

If I am still unable to explain it properly, then, all I want is to make something like the FaceBook photo album.

I know how to display a single image etc..

I wrote code to generate thumbnails.

I just need help displaying the list of images (as images, not text) in a listview. (A custom listview or some other control will be fine too). I have only ~40 images to show, so performance is not an issue.

Thanks a lot in advance

Nikita Nova

Link to comment
Share on other sites

  • Moderators

Hi, nikitanova. Rather than a listview, why not use GUICtrlCreatePic? You can then set the action for each thumbnail to be opening the picture in the default viewer. Something like this should give you what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg
GUICreate("My Pics")
GUISetState(@SW_SHOW)
 
   $pic1 = GUICtrlCreatePic(@ScriptDir & "1.jpg", 10, 10, 75, 75)
   $pic2 = GUICtrlCreatePic(@ScriptDir & "2.jpg", 95, 10, 75, 75)

   While 1
        $msg = GUIGetMsg()
           Select
              Case $msg = $GUI_EVENT_CLOSE
                 ExitLoop
              Case $msg = $pic1
                 ShellExecute(@ScriptDir & "1.jpg")
              Case $msg = $pic2
                 ShellExecute(@ScriptDir & "2.jpg")
           EndSelect
    WEnd
GUIDelete()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Since you have ~40 pictures, it might be easier to loop through all the pictures. This creates all the pictures in the same position on the gui, and hides all but one of the pictures. There are 2 buttons for you to set which picture you are viewing:

#include <Array.au3>
#include <GUIConstantsEx.au3>
Global $hForm = GUICreate("Pictures", 280, 200)
Global $iPicCount = 40;
Global $avHPics[$iPicCount]
For $i = 1 To $iPicCount
$avHPics[$i-1] = GUICtrlCreatePic(@ScriptDir & "pic" & $i & ".png", 100, 50, 100, 100)
GUICtrlSetState(-1, $GUI_HIDE)
Next
Global $hButtonLeft = GUICtrlCreateButton("<-----", 20, 50, 60, 25)
Global $hButtonRight = GUICtrlCreateButton("----->", 220, 50, 60, 25)
Global $iCurrentPic = 1; 1-based index of the currently shown picture
GUICtrlSetState($avHPics[0], $GUI_SHOW)
GUISetState()
Global $msg
While 1
$msg = GUIGetMsg()
Switch $msg
  Case -3
   Exit
  Case $avHPics[0] To $avHPics[$iPicCount-1]
   ShellExecute(@ScriptDir & "pic" & $avHPics[_ArraySearch($avHPics, $msg) + 1] & ".png")
  Case $hButtonLeft
   GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_HIDE)
   $iCurrentPic -= 1
   If $iCurrentPic < 1 Then $iCurrentPic = $iPicCount
   GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_SHOW)
  Case $hButtonRight
   GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_HIDE)
   $iCurrentPic += 1
   If $iCurrentPic > $iPicCount Then $iCurrentPic = 1
   GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_SHOW)
EndSwitch
WEnd
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...