Jump to content
Sign in to follow this  

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

Share this post

Link to post
Share on other sites

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")
   $pic1 = GUICtrlCreatePic(@ScriptDir & "1.jpg", 10, 10, 75, 75)
   $pic2 = GUICtrlCreatePic(@ScriptDir & "2.jpg", 95, 10, 75, 75)

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

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
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)
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)
Global $msg
While 1
$msg = GUIGetMsg()
Switch $msg
  Case -3
  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)

Share this post

Link to post
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
Sign in to follow this  

  • Similar Content

    • Epic007
      By Epic007
      Hey guys I'm stuck with a program.....I need a make an automation which copies text from a chat bot app and paste it in notepad to log the replies of my chat bot and to analyse stuff....a lil help pls
      Thanks in advance
    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Broihon
      By Broihon
      Hey guys,

      I ran into a problem when I wanted to delete items of a listview using the delete key. My approach is to register my own WndProc for the listview and then filter the $WM_GETDLGCODE msg and then call the original WndProc.
      That works like a charm. The problem is that when the listview gets redrawn it somehow ends up in an infinite loop. The listview is suddenly emtpy and I can't interact with any controls of the GUI at all. Here's the code:
      #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WinAPI.au3> $h_GUI = GUICreate("Test", 200, 200, 350, 350) $h_LV = GUICtrlCreateListView("Col 1|Col 2|Col 3", 0, 0, 200, 200) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 0) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 1) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 0) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 1) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 0) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 1) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 0) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 1) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 2) $h_LV_NewWndProc = DllCallbackRegister("WndProc_LV", "int", "hwnd;uint;wparam;lparam") $g_LV_OldWndProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($h_LV), $GWL_WNDPROC, DllCallbackGetPtr($h_LV_NewWndProc)) GUISetState(@SW_SHOW) Func WndProc_LV($hWnd, $uMsg, $wParam, $lParam) Return _WinAPI_CallWindowProc($g_LV_OldWndProc, $hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>WndProc_GUI Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCallbackFree($h_LV_NewWndProc) As you can see I'm doing nothing in the WndProc of the listview. I'm simply calling the original WndProc. This still "freezes" when I mess with the width of the columns or in the original project when I add more items that they don't fit in the listview and I have to scroll. If I don't do that it's working fine.
    • c.haslam
      By c.haslam
      I have
      Local $idListview = GUICtrlCreateListView("",8,8,@DesktopWidth/2-16,@DesktopHeight-150,$LVS_SHOWSELALWAYS, _ $LVS_EX_INFOTIP) Local $hListView = GUICtrlGetHandle($idListview) _GUICtrlListView_InsertColumn($hListview, 0, "Filename", 400) _GUICtrlListView_InsertColumn($hListview, 1, "Ext", 50) _GUICtrlListView_InsertColumn($hListview, 2, "Size",70) _GUICtrlListView_InsertColumn($hListview, 3, 'Date time',100) _GUICtrlListView_InsertColumn($hListview, 4, "Path", 385) _GUICtrlListView_InsertColumn($hListview, 5, "sizeInt", 0) _GUICtrlListView_JustifyColumn($hListview, $kSize,1) ; right align then further on
      While True $sFnamExt = FileFindNextFile($iSrch) If @error Then ExitLoop EndIf $sAtts = FileGetAttrib($sPath&'\'&$sFnamExt) If StringInStr($sAtts,'D') Then If $sFnamExt<>'$RECYCLE.BIN' Then $sDirs &= '?'&$sPath&'\'&$sFnamExt EndIf Else $p = StringInStr($sFnamExt,'.',0,-1) ; last If $p=0 Then $sFnam = $sFnamExt $sExt = '' Else $sFnam = StringLeft($sFnamExt,$p-1) $sExt = StringTrimLeft($sFnamExt,$p) EndIf _GUICtrlListView_AddItem($hListview,$sFnam,-1,_GUICtrlListView_GetItemCount($hListview)+1000) _GUICtrlListView_AddSubItem($hListview,$nItem,$sExt,$kExt) $nSize = FileGetSize($sPath&'\'&$sFnamExt) $sSize = AddThousandsSeparator($nsize) _GUICtrlListView_AddSubItem($hListview,$nItem,$sSize,$kSize) _GUICtrlListView_AddSubItem($hListview,$nItem,$nsize,$kSizeInt) $nTotBytes += $nSize $a1 = FileGetTime($sPath&'\'&$sFnamExt,$FT_MODIFIED,$FT_ARRAY) $t = $a1[0]&'-'&$a1[1]&'-'&$a1[2]&' '&$a1[3]&':'&$a1[4] _GUICtrlListView_AddSubItem($hListview,$nItem,$t,$kDateTime) _GUICtrlListView_AddSubItem($hListview,$nItem,$sPath,$kPath) If $gSQL Then $s = "Insert into tbl values ("&_SQLite_Escape($sFnam)&","&_SQLite_Escape($sExt)&",'"& _ $sSize&"','"& _ $t&"',"&_SQLite_Escape($sPath)&","&$nSize&")" _SQLite_Exec(-1,$s) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf EndIf EndIf WEnd FileClose($iSrch) You will see that I heeded the advice in Help > _GUICtrlListView_AddItem: "As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended."
      (It's unfortunate that the Example does not heed this advice. OK, it doesn't need to because there are no other controls, but still --- it would help neophytes if it did. Also to me _GUICtrlListView_AddItem is not native because it is a UDF. Confused?)
      My script then does a sort using SQLite, and updates the ListView:
      Local $hQuery Local $colNames = ['fnam','ext','nsize','dateTime','path','SizeInt'] Local $s = "Select * FROM tbl ORDER BY "&$colNames[$ncol]&';' _SQLite_Query(-1,$s, $hQuery) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf Local $aRow[$kSizeInt+1] Local $iItem=-1 While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) EndIf $iItem += 1 For $i = $kFnam To $kSizeInt _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default) Next WEnd This works, but I had earlier coded
      _GUICtrlListView_SetItem($hListview,$aRow[$i],$iItem,$i,Default,$iItem+1000) because the same advice is in the Help for this function.
      So my care in specifying $param back-fired! What am I not understanding?
      The only difference in what works is that the $param parameter is defaulted.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I am building a management for the company I work with, and I just imported a real amount of rows ( about 29000 ), in my SQLite DB.
      The thing I am not understanding, is the time that the script takes to build this amount of rows in the ListView.
      I didn't measure it, but I think it took 2 minutes or so to create each ListView item...
      It is normal that it takes so much time?
      What can I do to improve the creation of the items?

      Here's the code I am using to query and to create ListView items...
      ; Articles ListView: Global $lvwArticles = GUICtrlCreateListView("ID|Fornitore|Codice|Descrizione|EU|Prezzo|Sconto Applicato|Note", 14, 87, 1507, 660, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SORTASCENDING,$LVS_SORTDESCENDING), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) ; Query $strQuery = "SELECT * FROM ARTICOLI;" ; Query Execution _SQLite_GetTable2d($objDatabase, $strQuery, $arrResult, $intRows, $intColumns) If @error Then ; Error Handling Else ; Cleaning the ListView _GUICtrlListView_DeleteAllItems($lvwArticles) If @error Then ; Error Handling Else ; No records in the Table If UBound($arrResult) < 2 Then ; Error Handling Else _GUICtrlListView_BeginUpdate($lvwArticles) For $intCounter = 1 To UBound($arrResult) - 1 $strListViewItem = $arrResult[$intCounter][0] & "|" & _ $arrResult[$intCounter][1] & "|" & _ $arrResult[$intCounter][2] & "|" & _ $arrResult[$intCounter][3] & "|" & _ $arrResult[$intCounter][4] & "|" & _ $arrResult[$intCounter][5] & "|" & _ $arrResult[$intCounter][6] & "|" & _ $arrResult[$intCounter][7] $objListViewItem = GUICtrlCreateListViewItem($strListViewItem, $lvwArticles) Next _GUICtrlListView_EndUpdate($lvwArticles) EndIf EndIf EndIf Thanks in advance

      Best Regards.