rootx Posted November 24, 2015 Posted November 24, 2015 (edited) Hello guys, I would like to upload images in listview from a folder, but it does not work well, the list view repeat random the jpg!!But if I use _GUICtrlListView_SetImageList($idListview, $hImage, 1) the array work fine because write all images paths, the problem come when I try to see the images, where did i do wrong?THXexpandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage GUICreate("ImageList AddBitmap", 800, 600) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(64, 64) ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\Nuova cartella", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 _GDIPlus_Startup() For $y = 1 To $fileArray $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ;Add items _GUICtrlListView_AddItem($idListview, $aArray[$y], $img) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete() Edited November 25, 2015 by rootx
LarsJ Posted November 25, 2015 Posted November 25, 2015 This works for me. I've just been a little bit more accurate with regard to definitions of listview and image list.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage GUICreate("ImageList AddBitmap", 800, 600) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_ICON)) ; <<<<<<<< _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_DOUBLEBUFFER) ; <<<<<<<< _GUICtrlListView_SetView( $idListview, 1 ) ; 1 = Large icon <<<<<<<< GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(64, 64, 5, 3) ; <<<<<<<< _GUICtrlListView_SetImageList($idListview, $hImage ) ; <<<<<<<< ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) Local $aArray = _FileListToArrayRec("C:\WINDOWS\Temp\AutoIt", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 _GDIPlus_Startup() For $y = 1 To $fileArray Global $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image! Global $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image Global $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) ;_GUICtrlListView_SetImageList($idListview, $hImage, 1) ; <<<<<<<< ;Add items _GUICtrlListView_AddItem($idListview, $aArray[$y], $img) _GDIPlus_BitmapDispose($GDIpBmpLarge) ; <<<<<<<< _GDIPlus_BitmapDispose($GDIpBmpResized) ; <<<<<<<< _WinAPI_DeleteObject($GDIbmp) ; <<<<<<<< Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete()If this is not what you want, then please be more precise about the issues. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
rootx Posted November 25, 2015 Author Posted November 25, 2015 This works for me. I've just been a little bit more accurate with regard to definitions of listview and image list.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage GUICreate("ImageList AddBitmap", 800, 600) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_ICON)) ; <<<<<<<< _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_DOUBLEBUFFER) ; <<<<<<<< _GUICtrlListView_SetView( $idListview, 1 ) ; 1 = Large icon <<<<<<<< GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(64, 64, 5, 3) ; <<<<<<<< _GUICtrlListView_SetImageList($idListview, $hImage ) ; <<<<<<<< ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) Local $aArray = _FileListToArrayRec("C:\WINDOWS\Temp\AutoIt", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 _GDIPlus_Startup() For $y = 1 To $fileArray Global $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image! Global $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image Global $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) ;_GUICtrlListView_SetImageList($idListview, $hImage, 1) ; <<<<<<<< ;Add items _GUICtrlListView_AddItem($idListview, $aArray[$y], $img) _GDIPlus_BitmapDispose($GDIpBmpLarge) ; <<<<<<<< _GDIPlus_BitmapDispose($GDIpBmpResized) ; <<<<<<<< _WinAPI_DeleteObject($GDIbmp) ; <<<<<<<< Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete()If this is not what you want, then please be more precise about the issues.Thank LarsJ, but with your fix I do not see the images jpeg on the listview, I see only the path. I would like to see the images scaled.
LarsJ Posted November 25, 2015 Posted November 25, 2015 I have renamed a few of my images to "jpeg". Then I have changed "jpg" to "jpeg" in the script. It works for me. I see 64x64 pixel images in the listview. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
rootx Posted November 25, 2015 Author Posted November 25, 2015 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage, $g_bSortSense = True, $ini=@ScriptDir&"img.ini" Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\imgtest", "*.png", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 GUICreate("Image Album List", 800, 600) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState() ; Load images $hImage = _GUIImageList_Create(64, 64,5,3) _GUICtrlListView_SetImageList($idListview, $hImage ) ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) _GUICtrlListView_AddColumn($idListview, "Path", 128) _GUICtrlListView_AddColumn($idListview, "Caption", 500) ;_GUICtrlListView_HideColumn($idListview, 1) _GDIPlus_Startup() Local $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp For $y = 1 To $fileArray ;$ini = IniWrite("img.ini",$aArray[$y],"caption",$aArray[$y]) ;<<< run only the first time, then put a comment $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ;Add items _GUICtrlListView_AddItem($idListview, StringRegExp($aArray[$y], ".*\\(.+)$", 1), $img) ;image _GUICtrlListView_AddSubItem($idListview, $y-1,$aArray[$y],1) _GUICtrlListView_AddSubItem($idListview, $y,IniRead("img.ini",$aArray[$y],"caption",""),2) ;caption ConsoleWrite($img&" "&$aArray[$y]&@LF) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $idListview If Not IsHWnd($idListview) Then $hWndListView = GUICtrlGetHandle($idListview) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $path = IniRead("cfg.ini","PAGE","sourcedir","") Local $iItemText = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),2) Local $iLen = _GUICtrlListView_GetStringWidth($idListview, $iItemText) Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100") $iIndex = _GUICtrlListView_GetSelectedIndices($idListview) _GUICtrlListView_SetItemText($idListview,$iIndex,$sValue,2) If $sValue <> "" Then IniWrite("img.ini",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1),"caption",$sValue) Else _GUICtrlListView_SetItemText($idListview,$iIndex,$iItemText,3) EndIf Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) ; Kick off the sort callback _GUICtrlListView_SortItems($idListview, _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1)) Case $LVN_COLUMNCLICK ; A column was clicked _GUICtrlListView_SimpleSort($idListview, $g_bSortSense, 1, true) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) MsgBox($MB_ICONINFORMATION,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1)) Return 0 ; allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Ok, I upload all...I want to take pictures from a folder, enter them in the listview, right mouse button to see the path, double click left button writes a description in an ini file, when I will restart the script I want to see the description entered before. Edited November 25, 2015 by rootx
LarsJ Posted November 25, 2015 Posted November 25, 2015 (edited) Try this. I have not coded everything but focused on the listview.expandcollapse popup#include <GUIConstants.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GDIPlus.au3> #include <File.au3> Opt( "MustDeclareVars", 1 ) #cs ; Needed on AutoIt 3.3.10 Global Const $FLTAR_FILESFOLDERS = 0 Global Const $FLTAR_FILES = 1 Global Const $FLTAR_FOLDERS = 2 Global Const $FLTAR_NOHIDDEN = 4 Global Const $FLTAR_NOSYSTEM = 8 Global Const $FLTAR_NOLINK = 16 Global Const $FLTAR_NORECUR = 0 Global Const $FLTAR_RECUR = 1 Global Const $FLTAR_NOSORT = 0 Global Const $FLTAR_SORT = 1 Global Const $FLTAR_FASTSORT = 2 Global Const $FLTAR_NOPATH = 0 Global Const $FLTAR_RELPATH = 1 Global Const $FLTAR_FULLPATH = 2 #ce Global $hListView, $idOnLvRightClick, $idOnLvDoubleClick Example() Func Example() GUICreate( "Image Album List", 800, 650 ) Local $idListView = GUICtrlCreateListView("", 2, 2, 796, 646, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_AddColumn($idListView, "Image", 140) ; Must not be too small _GUICtrlListView_AddColumn($idListView, "Path", 128) _GUICtrlListView_AddColumn($idListView, "Caption", 450) $hListView = GUICtrlGetHandle( $idListView ) Local $hImage = _GUIImageList_Create(128, 128, 5, 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) $idOnLvDoubleClick = GUICtrlCreateDummy() $idOnLvRightClick = GUICtrlCreateDummy() _GDIPlus_Startup() Local $aArray = _FileListToArrayRec(".", "*.jpg;*.jpeg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) Local $iArray = UBound($aArray) - 1, $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp,$img For $i = 1 To $iArray - 1 $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$i]))) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 128,128) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp ) _GUICtrlListView_AddItem($idListview, "", $img) _GUICtrlListView_AddSubItem($idListview, $i-1,$aArray[$i],1) _GUICtrlListView_AddSubItem($idListview, $i-1,IniRead("img.ini",$aArray[$i],"caption",""),2) _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) Next _GDIPlus_Shutdown() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $idOnLvDoubleClick Local $iIndex = GUICtrlRead( $idOnLvDoubleClick ) Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100") Case $idOnLvRightClick Local $iIndex = GUICtrlRead( $idOnLvRightClick ) MsgBox(0,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, $iIndex,1)) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) GUICtrlSendToDummy( $idOnLvDoubleClick, DllStructGetData($tInfo, "Index") ) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) GUICtrlSendToDummy( $idOnLvRightClick, DllStructGetData($tInfo, "Index") ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncImages.7z Edited November 25, 2015 by LarsJ JoeBar 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
rootx Posted November 25, 2015 Author Posted November 25, 2015 I'm sorry but I can not see the images properly. I added some random pictures and you see some images are not rendered correctly.I am attaching these images but you may try any other image jpg. imgtest.7z
UEZ Posted November 25, 2015 Posted November 25, 2015 Use$GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($aArray[$i]) ;GDI+ image!and it should work. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
LarsJ Posted November 26, 2015 Posted November 26, 2015 UEZ, What's the difference when using your command? I must admit that I can not see any difference. To me, all the images looks fine with both commands including the images in imgtest.7z (apart from proportions because rectangular images are scaled into square images). Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
UEZ Posted November 26, 2015 Posted November 26, 2015 (edited) On my PC I get the same issue as rootx. The problem seems to be how the file are opened - not the GDIPlus functions.This will also work properly:$h = FileOpen($aArray[$i], 16) $b = FileRead($h) FileClose($h) $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory($b) ;GDI+ image!I don't know why two files are failing when they are loaded via$GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$i])))Maybe an internal conversation during the load is made for both images. Btw, _GDIPlus_BitmapCreateFromMemory() is not made to load images from disk, rather from memory! Edited November 26, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
rootx Posted November 26, 2015 Author Posted November 26, 2015 (edited) THX UEZ, _GDIPlus_BitmapCreateFromMemory() is not made to load images from disk, rather from memory!... is true. Edited November 26, 2015 by rootx
rootx Posted November 26, 2015 Author Posted November 26, 2015 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $idListview, $hImage, $ini=@ScriptDir&"img.ini" GUICreate("Image Album List", 800, 700) $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState() ; Load images $hImage = _GUIImageList_Create(64, 64,5,3) _GUICtrlListView_SetImageList($idListview, $hImage ) ; Add columns _GUICtrlListView_AddColumn($idListview, "Image", 64) _GUICtrlListView_AddColumn($idListview, "Path", 350) _GUICtrlListView_AddColumn($idListview, "Caption",382) ;_GUICtrlListView_HideColumn($idListview, 1) _GDIPlus_Startup() Local $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\1", "*.png", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 For $y = 1 To $fileArray ;$ini = IniWrite("img.ini",$aArray[$y],"caption",$aArray[$y]) ;<<< run only the first time, then put a comment $GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($aArray[$y]) ;GDI+ image! $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ;Add items _GUICtrlListView_AddItem($idListview, StringRegExp($aArray[$y], ".*\\(.+)$", 1), $img) ;image _GUICtrlListView_AddSubItem($idListview, $y-1,$aArray[$y],1) _GUICtrlListView_AddSubItem($idListview, $y-1,IniRead("img.ini",$aArray[$y],"caption",""),2) ;caption ConsoleWrite($img&" "&$aArray[$y]&@LF) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $idListview If Not IsHWnd($idListview) Then $hWndListView = GUICtrlGetHandle($idListview) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $path = IniRead("cfg.ini","PAGE","sourcedir","") Local $iItemText = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),2) ;Local $iLen = _GUICtrlListView_GetStringWidth($idListview, $iItemText) Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100",400,150) Local $iIndex = _GUICtrlListView_GetSelectedIndices($idListview) _GUICtrlListView_SetItemText($idListview,$iIndex,$sValue,2) If $sValue <> "" Then IniWrite("img.ini",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1),"caption",$sValue) Else _GUICtrlListView_SetItemText($idListview,$iIndex,$iItemText,3) EndIf Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) ; Kick off the sort callback _GUICtrlListView_SortItems($idListview, _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1)) Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) MsgBox($MB_ICONINFORMATION,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1)) Return 0 ; allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFYWhy is writing a blank line at the end of the for loop? I would like to avoid it, can someone explain to me?THX
UEZ Posted November 26, 2015 Posted November 26, 2015 This line shouldn't be clickable. It it caused by the GUICtrlCreateListView()For example if you use 16x16 images you will see a lot of more lines because it is created automatically. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
LarsJ Posted November 27, 2015 Posted November 27, 2015 I still have not been able to verify the problem with the previous image being displayed several times in place of new images. Windows 7 32/64. AutoIt 3.3.10.The ghost row in bottom of listview:You can work around the problem by carefully adjusting the height of the listview to match a whole number of rows. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
gcue Posted December 18, 2015 Posted December 18, 2015 just wanted to say thank you for this example.. works great!
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