JackDinn Posted August 22, 2008 Share Posted August 22, 2008 hi, quick question, im trying to list a dir full of photos as thumb nails. the only way i found to do it was to make a new window and then using a couple of for-next loops display each file as a pic using GUIctrlcreatePic going across and then down the window but iv looked at how windows does it by using the AU3Info tool and the opening up my picture folder and setting it to view thumbs, the info tool says the the display area that windows is using is a ListView type Ctrl but im dammed if i can get a ListView control to display thumbs all i can get is a list of the file names but not the actual pics? i have noticed the style and exStyle for listview do have some options $LVS_ICON & $LVS_SMALLICON but im really not sure about these options. been using AutoIt for quite a while but mainly on non-GUI stuff but i wanted to start learning the GUI side of AI. Thx all, Jack Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted August 22, 2008 Author Share Posted August 22, 2008 (edited) hi, quick question, im trying to list a dir full of photos as thumb nails. the only way i found to do it was to make a new window and then using a couple of for-next loops display each file as a pic using GUIctrlcreatePic going across and then down the window but iv looked at how windows does it by using the AU3Info tool and the opening up my picture folder and setting it to view thumbs, the info tool says the the display area that windows is using is a ListView type Ctrl but im dammed if i can get a ListView control to display thumbs all i can get is a list of the file names but not the actual pics? i have noticed the style and exStyle for listview do have some options $LVS_ICON & $LVS_SMALLICON but im really not sure about these options. been using AutoIt for quite a while but mainly on non-GUI stuff but i wanted to start learning the GUI side of AI. Thx all, Jack grr iv spent the last few hours trying to figure this out but im more confused than i was before! i have condensed my problem so it may be easer to explain what im having a problem with. so my test code: #include <guiconstants.au3> #include <misc.au3> $gui=GUICreate("fred",1200,900,-1,-1) $lv=GUICtrlCreateListView("lv|test|fred",0,50,1000,800,$LVS_ICON) GUISetState() GUICtrlCreateListViewItem("test|test",$lv) GUICtrlCreateListViewItem("test",$lv) GUICtrlCreateListViewItem("test",$lv) GUICtrlCreateListViewItem("test",$lv) While 1 $msg=GUIGetMsg() If $msg=$gui_event_close Then Exit If _IsPressed(51) Then ; "q" on the keyboard ControlListView("fred","","SysListView321","ViewChange","largeicons") If @error Then Exit EndIf Sleep(50) WEnd so what is the $LVS_ICON style if it doesn't display icons in the list view ? why does ControlListView("fred","","SysListView321","ViewChange","largeicons") not change the list to icons? head ache now but any help would b great Thx all, Jack. Edited August 22, 2008 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
smashly Posted August 22, 2008 Share Posted August 22, 2008 (edited) Hi, Here's a crude example of displaying 100x100 thumbnails of images (bmp,gif,jpg,png,tif).Just drop a folder into the listview ..Be warned it's using a recursive search so if you drop a folder with lots of folders inside it then the it will be slow to populate the listview!expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Global $hImageList, $Title = "Drop a folder (searches recursive for pictures)" $hGui = GUICreate($Title, 520, 400, 0, 0, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiEvent", $hGui) GUISetOnEvent($GUI_EVENT_DROPPED, "_GuiEvent", $hGui) $LV = GUICtrlCreateListView("", 5, 5, 510, 390, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER)) GUICtrlSetTip(-1, "Drop folder containing images here.") GUICtrlSetState(-1, $GUI_DROPACCEPTED) _GUICtrlListView_SetView($LV, 1) _GUICtrlListView_SetIconSpacing($LV, 120, 20) GUISetState() While 1 Sleep(100) WEnd Func _GuiEvent() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED _Dropped(@GUI_DragFile) EndSwitch EndFunc ;==>_GuiEvent Func _Dropped($sPath) GUICtrlSetState($LV, $GUI_DISABLE) WinSetTitle($hGui, "", "Searching for images to load.....") Local $FL2AR = _FileListToArrayR($sPath, "bmp|gif|jpg|png|tif", 1, 1) If Not @error Then If $hImageList Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV)) _GUIImageList_Destroy($hImageList) $hImageList = 0 EndIf $hImageList = _GUIImageList_Create(100, 100, 5, 3, $FL2AR[0]) For $i = 1 To $FL2AR[0] Local $hGT = _GetThumb($FL2AR[$i], 100, 100) _GUIImageList_Add($hImageList, $hGT) _WinAPI_DeleteObject($hGT) Next _GUICtrlListView_SetImageList($LV, $hImageList, 0) For $i = 1 To $FL2AR[0] _GUICtrlListView_AddItem($LV, StringTrimLeft($FL2AR[$i], StringInStr($FL2AR[$i], "\", 0, -1)), $i - 1) Next EndIf WinSetTitle($hGui, "", $Title) GUICtrlSetState($LV, $GUI_ENABLE) EndFunc ;==>_Dropped Func _GetThumb($sFile, $iW, $iH) Local $hImage, $aResult, $hThumb _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFile) $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageThumbnail", "hwnd", $hImage, "int", $iW, "int", $iH, _ "int*", 0, "ptr", 0, "ptr", 0) $hThumb = _GDIPlus_BitmapCreateHBITMAPFromBitmap($aResult[4]) _GDIPlus_ImageDispose($aResult[4]) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $hThumb EndFunc ;==>_GetThumb Func _FileListToArrayR($sPath, $sExFilter = "", $iFlag = 0, $iRecurse = 0, $iDepth = 0) Local $hSearch, $sFile, $sRxpFilter, $asFileList If Not $iDepth Then Global $sHoldFiles = '' If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sExFilter, "[\\/<>:*?]", 0) Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") If Not ($iRecurse = 0 Or $iRecurse = 1) Then Return SetError(4, 4, "") EndIf If StringRight($sPath, 1) <> "\" Then $sPath &= "\" If $sExFilter = "" Then $sRxpFilter = "." Else $sRxpFilter = "(?i)\.(" & $sExFilter & ")" EndIf $hSearch = FileFindFirstFile($sPath & "*") If $hSearch = -1 Then Return SetError(5, 5, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sPath & $sFile), "D") Then If Not $iRecurse And $iFlag = 1 Then ContinueLoop If $iRecurse Then _FileListToArrayR($sPath & $sFile, $sExFilter, $iFlag, $iRecurse, $iDepth + 1) If $iFlag <> 1 Then $sHoldFiles &= $sPath & $sFile & "|" Else $sHoldFiles &= $sPath & $sFile & "|" EndIf ElseIf StringRegExp($sFile, $sRxpFilter, 0) And $iFlag <> 2 Then $sHoldFiles &= $sPath & $sFile & "|" EndIf WEnd FileClose($hSearch) If Not $iDepth Then $asFileList = StringSplit(StringTrimRight($sHoldFiles, 1), "|") $sHoldFiles = "" Return $asFileList EndIf EndFunc ;==>_FileListToArrayRCheersP.S. The thumbnails are not scaled keeping aspect ratio of the original image, that would require a bit more effort. Edited August 22, 2008 by smashly Link to comment Share on other sites More sharing options...
JackDinn Posted August 22, 2008 Author Share Posted August 22, 2008 (edited) hmm, well for some reason i dont have any <GDIPlus.au3> so it dont run, but i shall c if i can pick out what i need to know from your script. thx for your time. jack Edited August 22, 2008 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted August 22, 2008 Author Share Posted August 22, 2008 hmm, well for some reason i dont have any <GDIPlus.au3> so it dont run, but i shall c if i can pick out what i need to know from your script.thx for your time.jackim just stumbling in the dark here, the instructions say "To use these GUI Control Style values you must #include <GUIConstants.au3> into your script. " but GUIConstants.au3 does not contain $LVS_EX_DOUBLEBUFFER ??so whenever i put $LV = GUICtrlCreateListView("", 5, 5, 510, 390, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER))i just get WARNING: $LVS_EX_DOUBLEBUFFER: possibly used before declaration, even though i have "#include <GUIconstants.au3>" at the top.Also the Autoit help says absolutely nothing about what $LVS_EX_DOUBLEBUFFER doesThx Jack Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted August 22, 2008 Author Share Posted August 22, 2008 im just stumbling in the dark here, the instructions say "To use these GUI Control Style values you must #include <GUIConstants.au3> into your script. " but GUIConstants.au3 does not contain $LVS_EX_DOUBLEBUFFER ??so whenever i put $LV = GUICtrlCreateListView("", 5, 5, 510, 390, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER))i just get WARNING: $LVS_EX_DOUBLEBUFFER: possibly used before declaration, even though i have "#include <GUIconstants.au3>" at the top.Also the Autoit help says absolutely nothing about what $LVS_EX_DOUBLEBUFFER doesThx Jackok iv updated AI and have got all the missing UDF`s and #include files now so i should be able to sus out what i need from you script "which works fine now" so thx for that no all i have to do is pick it apart and understand it Thx again,Jack. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted August 22, 2008 Author Share Posted August 22, 2008 ok iv updated AI and have got all the missing UDF`s and #include files now so i should be able to sus out what i need from you script "which works fine now" so thx for that no all i have to do is pick it apart and understand it Thx again,Jack.sorry for the multi posts.however i have been through you script and my first thought was what a lot of messing just to display a thumb list,but i do have 1 question, how is this right $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageThumbnail", "hwnd", $hImage, "int", $iW, "int", $iH, _i cant see how you can call an undeclared Dll, $ghGDIPDll is not defined anywhere and looks to me like a variable string not a .DLL name ? anyhow thx again.Jack. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 22, 2008 Share Posted August 22, 2008 sorry for the multi posts.however i have been through you script and my first thought was what a lot of messing just to display a thumb list,but i do have 1 question, how is this right $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageThumbnail", "hwnd", $hImage, "int", $iW, "int", $iH, _i cant see how you can call an undeclared Dll, $ghGDIPDll is not defined anywhere and looks to me like a variable string not a .DLL name ? anyhow thx again.Jack.If that variable was undeclared the script would never run, and a quick search shows that it is declared in GDIPlus.au3.Now why didn't you search yourself? It would have taken less time than to post here... .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
JackDinn Posted August 23, 2008 Author Share Posted August 23, 2008 If that variable was undeclared the script would never run, and a quick search shows that it is declared in GDIPlus.au3.Now why didn't you search yourself? It would have taken less time than to post here... yea i did figure it out a little while after posting, its the new UDF`s that im just looking at now that throw me soz "we all started at the beginning with many question"Thx anyhow, im sure this wont b my last silly post either Thx Jack. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
ThomasPaul Posted March 7, 2009 Share Posted March 7, 2009 grr iv spent the last few hours trying to figure this out but im more confused than i was before! i have condensed my problem so it may be easer to explain what im having a problem with. so my test code: #include <guiconstants.au3> #include <misc.au3> $gui=GUICreate("fred",1200,900,-1,-1) $lv=GUICtrlCreateListView("lv|test|fred",0,50,1000,800,$LVS_ICON) GUISetState() GUICtrlCreateListViewItem("test|test",$lv) GUICtrlCreateListViewItem("test",$lv) GUICtrlCreateListViewItem("test",$lv) GUICtrlCreateListViewItem("test",$lv) While 1 $msg=GUIGetMsg() If $msg=$gui_event_close Then Exit If _IsPressed(51) Then; "q" on the keyboard ControlListView("fred","","SysListView321","ViewChange","largeicons") If @error Then Exit EndIf Sleep(50) WEnd so what is the $LVS_ICON style if it doesn't display icons in the list view ? why does ControlListView("fred","","SysListView321","ViewChange","largeicons") not change the list to icons? head ache now but any help would b great Thx all, Jack. HI Smashly, this is my very 1st post so pls forgive me if I'm doing something stupid or wrong ...... I noticed ur above posting and I find it very usefull for one of my projects. I got a question regarding the resulting ListView-Control in ur program: After dragging a directory onto the gui I receive a LV-control with a VERTICAL scrollbar. Do you know any way how to build the LV-control without this VERTICAL scrollbar ... but with a HORIZONTAL one??? I searched the forum and played around for 2 days now - but seems that I'm unable to find a solution by my own. Any Ideas? Thx in advance, tom Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now