Wonvy Posted April 23, 2011 Share Posted April 23, 2011 I think in the listview display pictures like Windows resource manager like that English is not useful software translation, don't mind,I myself find examples are ICONS list Which experienced, give an example, thank you On the right side of the rectangular frame to put pictures within thumbnails Link to comment Share on other sites More sharing options...
Jayson Posted April 26, 2011 Share Posted April 26, 2011 (edited) This might help you out on your projet : expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <File.au3> #Include <EditConstants.au3> #Include <Constants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $sExtFilter = "bmp|gif|jpeg|jpg|png|tif|tiff" Global $hGui, $Path, $BRowse, $LV, $Pic, $Msg Global $hImageList, $sCur, $sLast, $iDX, $iPicState = 0, $DoubleClick = -1 $hGui = GUICreate("Image Viewer", 490, 620) $Path = GUICtrlCreateInput("", 10, 10, 400, 20, $ES_READONLY) $BRowse = GUICtrlCreateButton("Browse", 420, 10, 60, 20) $LV = GUICtrlCreateListView("", 5, 40, 480, 575, -1, BitOr($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_SetView($LV, 1) _GUICtrlListView_SetIconSpacing($LV, 75, 60) $Pic = GUICtrlCreatePic("", 200, 80, 440, 440) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Browse _Browse() EndSwitch WEnd Func _Browse() Local $FSF, $FL2A, $hBmp, $iCnt = 0 $FSF = FileSelectFolder("Browse for folder containing pictures", "", "", $hGui) If Not @error And FileExists($FSF) Then If StringRight($FSF, 1) <> "\" Then $FSF &= "\" $FL2A = _FileListToArray($FSF, "*", 1) If Not @Error Then If IsPtr($hImageList) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV)) _GUiImageList_Destroy($hImageList) $hImageList = "" _hBmpToPicControl($Pic, $hBmp) GUICtrlSetImage($Pic, "") $iDX = -1 $iPicState = 0 $sCur = "" $sLast = "" EndIf $hImageList = _GUiImageList_Create(60, 60, 5, 3) _GUICtrlListView_SetImageList($LV, $hImageList, 0) For $i = 1 To $FL2A[0] If StringRegExp($FL2A[$i], "(?i)\.(" & $sExtFilter & ")", 0) Then $hBmp = _GetImage($FSF & $FL2A[$i], 60) _GUiImageList_Add($hImageList, $hBmp) _WinAPI_DeleteObject($hBmp) _GUICtrlListView_AddItem($LV, $FL2A[$i], $iCnt) _GUICtrlListView_SetItemImage($LV, $iCnt, $iCnt) $iCnt += 1 EndIf Next GUICtrlSetData($Path, $FSF) EndIf WinSetTitle($hGui, "", "Images Found: " & $iCnt) EndIf EndFunc Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF) Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2 _GDIPlus_Startup() $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hBmp1) _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) $hImage = _GDIPlus_ImageLoadFromFile($sFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $aGS = _GetScale($iW, $iH, $iWH) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $hBmp2 EndFunc Func _GetScale($iW, $iH, $iWH) Local $aRet[4] If $iW <= $iWH And $iH <= $iWH Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($iWH - $aRet[2])/2 $aRet[1] = ($iWH - $aRet[3])/2 ElseIf $iW > $iH Then $aRet[2] = $iWH $aRet[3] = $iH/($iW/$iWH) $aRet[0] = 0 $aRet[1] = ($iWH - $aRet[3])/2 ElseIf $iW < $iH Then $aRet[2] = $iW/($iH/$iWH) $aRet[3] = $iWH $aRet[0] = ($iWH - $aRet[2])/2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $iWH $aRet[3] = $iWH $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local $hOldBmp $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp) If $iFlag Then _WinAPI_DeleteObject($hBmp) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aIDX $hWndListView = GUICtrlGetHandle($LV) $tNMHDR = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code', $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK $iDX = _GUICtrlListView_GetNextItem($hWndListView) Case $NM_DBLCLK $DoubleClick = _GUICtrlListView_GetNextItem($hWndListView) Case $LVN_KEYDOWN $tInfo = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code;int_ptr VKey;int Flags', $ilParam) Switch BitAnd(DllStructGetData($tInfo, "VKey"), 0xFFFF) Case $VK_UP $iDX = _GUICtrlListView_GetNextItem($hWndListView) -1 If $iDX < 0 Then $iDX = 0 Case $VK_DOWN $iDX = _GUICtrlListView_GetNextItem($hWndListView) + 1 If $iDX >= _GUICtrlListView_GetItemCount($hWndListView) Then $iDX -= 1 EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited April 27, 2011 by Jayson Link to comment Share on other sites More sharing options...
guinness Posted April 26, 2011 Share Posted April 26, 2011 Nice Example Jayson! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JScript Posted April 27, 2011 Share Posted April 27, 2011 @Jayson, Excellent! How good share! I was thinking of something similar but did not have much idea how to to design. Thanks! http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
qwert Posted November 17, 2011 Share Posted November 17, 2011 Both useful and instructive. Thanks. Too bad it's not under Examples, where people could locate it more easily. Link to comment Share on other sites More sharing options...
Wonvy Posted September 3, 2012 Author Share Posted September 3, 2012 Thank you, could not speak English Link to comment Share on other sites More sharing options...
NassauSky Posted July 10, 2018 Share Posted July 10, 2018 On 4/26/2011 at 9:33 AM, Jayson said: This might help you out on your project : Really appreciate this demo but it runs and shows it found 2 images in a particular folder but nothing else. The main GUI is blank. Has anything changed in autoit since this was posted that might keep it from displaying the images in the folder? On 4/26/2011 at 9:33 AM, Jayson said: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <File.au3> #Include <EditConstants.au3> #Include <Constants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $sExtFilter = "bmp|gif|jpeg|jpg|png|tif|tiff" Global $hGui, $Path, $BRowse, $LV, $Pic, $Msg Global $hImageList, $sCur, $sLast, $iDX, $iPicState = 0, $DoubleClick = -1 $hGui = GUICreate("Image Viewer", 490, 620) $Path = GUICtrlCreateInput("", 10, 10, 400, 20, $ES_READONLY) $BRowse = GUICtrlCreateButton("Browse", 420, 10, 60, 20) $LV = GUICtrlCreateListView("", 5, 40, 480, 575, -1, BitOr($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_SetView($LV, 1) _GUICtrlListView_SetIconSpacing($LV, 75, 60) $Pic = GUICtrlCreatePic("", 200, 80, 440, 440) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Browse _Browse() EndSwitch WEnd Func _Browse() Local $FSF, $FL2A, $hBmp, $iCnt = 0 $FSF = FileSelectFolder("Browse for folder containing pictures", "", "", $hGui) If Not @error And FileExists($FSF) Then If StringRight($FSF, 1) <> "\" Then $FSF &= "\" $FL2A = _FileListToArray($FSF, "*", 1) If Not @Error Then If IsPtr($hImageList) Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV)) _GUiImageList_Destroy($hImageList) $hImageList = "" _hBmpToPicControl($Pic, $hBmp) GUICtrlSetImage($Pic, "") $iDX = -1 $iPicState = 0 $sCur = "" $sLast = "" EndIf $hImageList = _GUiImageList_Create(60, 60, 5, 3) _GUICtrlListView_SetImageList($LV, $hImageList, 0) For $i = 1 To $FL2A[0] If StringRegExp($FL2A[$i], "(?i)\.(" & $sExtFilter & ")", 0) Then $hBmp = _GetImage($FSF & $FL2A[$i], 60) _GUiImageList_Add($hImageList, $hBmp) _WinAPI_DeleteObject($hBmp) _GUICtrlListView_AddItem($LV, $FL2A[$i], $iCnt) _GUICtrlListView_SetItemImage($LV, $iCnt, $iCnt) $iCnt += 1 EndIf Next GUICtrlSetData($Path, $FSF) EndIf WinSetTitle($hGui, "", "Images Found: " & $iCnt) EndIf EndFunc Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF) Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2 _GDIPlus_Startup() $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hBmp1) _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) $hImage = _GDIPlus_ImageLoadFromFile($sFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $aGS = _GetScale($iW, $iH, $iWH) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $hBmp2 EndFunc Func _GetScale($iW, $iH, $iWH) Local $aRet[4] If $iW <= $iWH And $iH <= $iWH Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($iWH - $aRet[2])/2 $aRet[1] = ($iWH - $aRet[3])/2 ElseIf $iW > $iH Then $aRet[2] = $iWH $aRet[3] = $iH/($iW/$iWH) $aRet[0] = 0 $aRet[1] = ($iWH - $aRet[3])/2 ElseIf $iW < $iH Then $aRet[2] = $iW/($iH/$iWH) $aRet[3] = $iWH $aRet[0] = ($iWH - $aRet[2])/2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $iWH $aRet[3] = $iWH $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local $hOldBmp $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp) If $iFlag Then _WinAPI_DeleteObject($hBmp) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aIDX $hWndListView = GUICtrlGetHandle($LV) $tNMHDR = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code', $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK $iDX = _GUICtrlListView_GetNextItem($hWndListView) Case $NM_DBLCLK $DoubleClick = _GUICtrlListView_GetNextItem($hWndListView) Case $LVN_KEYDOWN $tInfo = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code;int_ptr VKey;int Flags', $ilParam) Switch BitAnd(DllStructGetData($tInfo, "VKey"), 0xFFFF) Case $VK_UP $iDX = _GUICtrlListView_GetNextItem($hWndListView) -1 If $iDX < 0 Then $iDX = 0 Case $VK_DOWN $iDX = _GUICtrlListView_GetNextItem($hWndListView) + 1 If $iDX >= _GUICtrlListView_GetItemCount($hWndListView) Then $iDX -= 1 EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
spudw2k Posted July 11, 2018 Share Posted July 11, 2018 On 7/10/2018 at 9:05 AM, nassausky said: Has anything changed in autoit since this was posted Well, considering the example post was made over 7 years ago, I'd wager yes. Looking at the Release History, the most recent version that the example could have been written in was version 3.3.6.1. So if you feel like doing detective work to see if a documented in the Script Breaking Change log is the cause, start with v3.3.8.0 and work your way up. If you don't find anything, start scrubbing through the script and check the returns from the function calls to find where the error(s) happen(s). Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
NassauSky Posted July 11, 2018 Share Posted July 11, 2018 Nice to hear your idea. Never knew they had a cool log called "Script Breaking Change Log" haha. Thanks again @spudw2k Link to comment Share on other sites More sharing options...
NassauSky Posted July 11, 2018 Share Posted July 11, 2018 You're a genius @spudw2k Turns out it was a simple change from 1 to 0 in line 21: _GUICtrlListView_SetView($LV, 1) ; Changing the last parameter from 1 to 0 did the magic There was a script breaking change in 3.3.12.0 _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's 0 for large icon view and 1 for detailed view. 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