Tin2tin Posted October 10, 2012 Share Posted October 10, 2012 (edited) When I use _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($Listview)) to delete items in a list the images are also deleted from the list, but when I add more items and images to the list things are messed up. Does _GUICtrlListView_DeleteItemsSelected also delete the images from the imagelist? If not I've tried to do it this way, but it doesn't work either: for $j=_GUICtrlListView_GetItemCount($Listview) to 0 step -1 if _GUICtrlListView_GetItemSelected($Listview, $j)=1 then _GUIImageList_Remove(GUICtrlGetHandle($hImage), $j) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($Listview), $j) endif next How do I avoid the image list beeing messed up after deleting some items and then add more items? Edited October 10, 2012 by Tin2tin DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 10, 2012 Share Posted October 10, 2012 "A bit messed up" is a rather vague statement as to what is happening. Could you post the code you're using so we can get some idea of what it is we're dealing with? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 10, 2012 Author Share Posted October 10, 2012 "A bit messed up" is a rather vague statement as to what is happening. Could you post the code you're using so we can get some idea of what it is we're dealing with? Sorry for not beeing more precise, but it seems like the imagelist items haven't been deleted correctly, so the newly added images are inserted after the insertion of the images which was supposed to be deleted. Here are some bits an pieces of the code: expandcollapse popupWhile 1 ;ConsoleWrite(GUIGetMsg()) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE cleanup() if ProcessExists("ffmbc.exe") then ProcessClose("ffmbc.exe") EXIT Case $GUI_EVENT_DROPPED If $__DropFiles[0] > 0 Then GUISetCursor(15, 1, $hGUI) for $i =1 to ubound($__DropFiles)-1 if ((_GUICtrlListView_GetItemCount($Listview)-1)+ubound($__DropFiles)-1)>499 Then msgbox(48, "Aborting Import", "A maximum of 500 clips can be converted.") exitloop endif ;GUICtrlSetData($process,Int(($lastreturn/$fulltime)*100)) GUICtrlSetData($process,Int(($i/ubound($__DropFiles))*100)) addtolist($__DropFiles[$i]) next GUICtrlSetData($process,Int(0)) GUISetCursor($old_cursor, 1, $hGUI) EndIf Case $btn if _GUICtrlListView_GetItemCount($Listview)>0 then $upload=false _Convert() GUISetCursor($old_cursor, 1, $hGUI) endif Case $btn_upload if _GUICtrlListView_GetItemCount($Listview)>0 then $upload=true _Convert() GUISetCursor($old_cursor, 1, $hGUI) endif Case $swapbtn _swap() Case $NM_DBLCLK MsgBox(4096, "listview", "clicked=" & GUICtrlGetState($Listview), 2) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>BatchConverter func addtolist($addfile) ConsoleWrite($addfile) if stringright($addfile,3)="ini" or stringright($addfile,3)="lnk" then return Local $attribute = FileGetAttrib($addfile) ; Retrieve the file/dir attributes If StringInStr($attribute, "D") Then ; If the attribute string contains the letter 'D' then it is a DIR. Local $FileList=_FileListToArray($addfile) if @error then else if $FileList[0]>0 Then for $f=1 to ubound($FileList)-1 GUICtrlSetData($process,Int(($f/ubound($FileList))*100)) addtolist($addfile&chr(92)&$FileList[$f]) next endif endif else $reuse=0 for $j=0 to _GUICtrlListView_GetItemCount($Listview) if $addfile=_GUICtrlListView_GetItemText($Listview, $j, 4) then $reuse=1 next if $reuse=0 then if ffprobetest($addfile) then ffthumb($addfile) $MyPath=_PathSplit($addfile, $szDrive, $szDir, $szFName, $szExt) if FileExists ( @TempDir&chr(92)&"EyeFrame"&chr(92)&"Thumbs"&chr(92)&$MyPath[3]&".bmp" ) <> 0 then $result=_GUIImageList_Add($hImage, _WinAPI_LoadImage(0, @TempDir&chr(92)&"EyeFrame"&chr(92)&"Thumbs"&chr(92)&$MyPath[3]&".bmp", $IMAGE_BITMAP, 96, 54, BitOr($LR_LOADFROMFILE, $LR_DEFAULTSIZE))) _GUICtrlListView_AddItem($Listview, "",_GUICtrlListView_GetItemCount($Listview)) _GUICtrlListView_AddSubItem($Listview, _GUICtrlListView_GetItemCount($Listview)-1,$addfile, 4, -1) _GUICtrlListView_AddSubItem($Listview, _GUICtrlListView_GetItemCount($Listview)-1,$MyPath[3]&$MyPath[4], 1, -1) _GUICtrlListView_AddSubItem($Listview, _GUICtrlListView_GetItemCount($Listview)-1,round(filegetsize($addfile)/1000000,2)&" MB", 2, -1) $t=FileGetTime($addfile) _GUICtrlListView_AddSubItem($Listview, _GUICtrlListView_GetItemCount($Listview)-1,$t[0] & "-" & $t[1] & "-" & $t[2]& " " & $t[3]& ":" & $t[4]& "." & $t[5], 3, -1) _GUICtrlListView_SetImageList($Listview, $hImage,1) _GUICtrlListView_EnsureVisible($ListView, _GUICtrlListView_GetItemCount($Listview)-1) GUISetState() endif Else MsgBox(48, "File", "Unable to import: "&$addfile) endif endif endif endfunc Func DeleteSelection() ;~ for $j=_GUICtrlListView_GetItemCount($Listview) to 0 step -1 ;~ if _GUICtrlListView_GetItemSelected($Listview, $j)=1 then ;~ ConsoleWrite($j) ;~ _GUIImageList_Remove(GUICtrlGetHandle($hImage), $j) ;~ ;msgbox(0,"","") ;~ _GUICtrlListView_DeleteItem(GUICtrlGetHandle($Listview), $j) ;~ ;_GUIImageList_Remove($hImage, $j) ;~ endif ;~ next ; _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($Listview)) ; _GUIImageList_Destroy($hImage) ; $hImage = _GUIImageList_Create(96, 54) ;~ _GUICtrlListView_SetImageList($Listview, $hImage, 1) ;~ for $i=1 to _GUICtrlListView_GetItemCount($Listview)-1 ;~ $MyPath=_PathSplit(_GUICtrlListView_GetItemText($Listview, $i, 4), $szDrive, $szDir, $szFName, $szExt) ;~ $result=_GUIImageList_Add($hImage, _WinAPI_LoadImage(0, @TempDir&chr(92)&"EyeFrame"&chr(92)&"Thumbs"&chr(92)&$MyPath[3]&".bmp", $IMAGE_BITMAP, 96, 54, BitOr($LR_LOADFROMFILE, $LR_DEFAULTSIZE))) ;~ ConsoleWrite($result) ;~ next ; GUISetState() _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($Listview)) EndFunc ;==>DeleteSelection DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 10, 2012 Share Posted October 10, 2012 Do you have any working code that I can run to demonstrate the problem? This is just a small part of the script and I can't see anything wrong with it as far as I can follow it, but it's much easier if you post a working script that reproduces the issue you're having. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 10, 2012 Author Share Posted October 10, 2012 (edited) I'm affraid it's big download, but here it is: http://download.videohelp.com/tin2tin/EyeFrameConverter.zip To reproduce the problem, add some video files, delete some of them with the del key and add some more video files. The file is called Eyeframe_source.au3. Edited October 10, 2012 by Tin2tin DVD slideshow GUI Link to comment Share on other sites More sharing options...
guinness Posted October 10, 2012 Share Posted October 10, 2012 (edited) I don't know what BrewManNH thinks, but provide a small reproducer instead of your entire program because that download is massive and a little difficult to read due to only a handful of comments. Edited October 10, 2012 by guinness 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...
BrewManNH Posted October 10, 2012 Share Posted October 10, 2012 I'm with guiness, something small that shows the problem without needing to drop videos on the GUI would be most helpful. Use bitmaps or icons for the image list, and it will make it far easier to see if it's a problem with the function, or a problem with your code. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 10, 2012 Author Share Posted October 10, 2012 I'm really sorry to post a link to the entire script, but I'm not around my computer, so I can only write from my phone. I'll try to make a stripped down version tomorrow. But I guess that the deleteselected function also is supposed to delete images in the image list? DVD slideshow GUI Link to comment Share on other sites More sharing options...
guinness Posted October 10, 2012 Share Posted October 10, 2012 When you do, just take the example from the Help file and change accordingly. 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...
BrewManNH Posted October 10, 2012 Share Posted October 10, 2012 This script demonstrates a Listview with an image list applied to it. I delete row 3 and the image assigned to the 3rd spot in the image list. Then I recreate row 3, add row 4 and also add 2 items to the image list. This demo works for me. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Get image list handle MsgBox(4160, "Information", "Deleting item 2") _GUIImageList_Remove($hImage, 2) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 2) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) MsgBox(4160, "Information", "Adding imagelist item 2 back in with new lv item and image") _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF8040, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x408080, 16, 16)) _GUICtrlListView_AddItem($hListView, "Item 3", 2) _GUICtrlListView_AddItem($hListView, "Item 4", 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main I took this from the example script in the help file, and modified it for demonstration purposes. It shows that there's nothing wrong with the image list removal or add commands, or the listview command that do the same. At least as far as I can determine. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 12, 2012 Author Share Posted October 12, 2012 (edited) Apparently the problem appears when it isn't the last item deleted. If the 2. last item is deleted this happens: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Get image list handle MsgBox(4160, "Information", "Deleting item 2") _GUIImageList_Remove($hImage, 1) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 1) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; msgbox(4160,"Total images in List",_GUIImageList_GetImageCount($hImage)) MsgBox(4160, "Information", "Adding imagelist item 2 back in with new lv item and image") _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF8040, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x408080, 16, 16)) _GUICtrlListView_AddItem($hListView, "Item 3", 2) _GUICtrlListView_AddItem($hListView, "Item 4", 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Edited October 12, 2012 by Tin2tin DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 12, 2012 Share Posted October 12, 2012 From running the script, it appears that when you add the image to the image list, it's appending it to the end of the list as I would expect, then what was image 3 becomes image 2 (because you deleted image 2 previously and the images move up the list as items are deleted), new image becomes image 3. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 12, 2012 Author Share Posted October 12, 2012 (edited) To me it seems like it is deleting one image too many and add pink to two items which is not correct.(I'm using v3.3.9.4 (beta)) Edited October 12, 2012 by Tin2tin DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 12, 2012 Share Posted October 12, 2012 This is my understanding of what's happening. Original Colors 0 - Red 1 - Green 2 - Blue Delete 2 0 - Red 1 - Blue Add new images 3 & 4 0 - Red 1 - Blue 2 - Pinkish 3 - Greenish Because previously Item 3 was set to use Image 2, it's now going to use the new image 2 color, which is the pinkish color. In investigating this, I found that there's a function which will reset the image used for an item in the list view, which would have to be called when applying the new image list. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Get image list handle MsgBox(4160, "Information", "Deleting item 2") _GUIImageList_Remove($hImage, 1) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 1) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; msgbox(4160,"Total images in List",_GUIImageList_GetImageCount($hImage)) MsgBox(4160, "Information", "Adding imagelist item 2 back in with new lv item and image") _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF8040, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x408080, 16, 16)) _GUICtrlListView_AddItem($hListView, "New Item 4", 2) _GUICtrlListView_AddItem($hListView, "New Item 5", 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) MsgBox(64, "Information", "Added items to the listview using the new image list" & @CRLF & "Now resetting the image used for Item 3 to use the correct image in the new image list.") _GUICtrlListView_SetItemImage($hListView, 1, 1) ; Resets which image Item 3 uses for it's image in the new image list. ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 12, 2012 Author Share Posted October 12, 2012 Woa, that seems to solve the problem. I would never have guessed that it is necessary to do this: _GUICtrlListView_SetItemImage($hListView, 1, 1) ; Resets which image Item 3 uses for it's image in the new image list. Maybe _GUICtrlListView_DeleteItemsSelected should have that function call added internally? Thank you so much. DVD slideshow GUI Link to comment Share on other sites More sharing options...
Tin2tin Posted October 12, 2012 Author Share Posted October 12, 2012 (edited) Hmm, maybe I don't understand that function correctly, because if I remove two items things go wrong again: expandcollapse popup#include #include #include $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; Get image list handle MsgBox(4160, "Information", "Deleting item 1 and 2") _GUIImageList_Remove($hImage, 1) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 1) _GUIImageList_Remove($hImage, 0) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($hListView), 0) Local $hPrevImageList = _GUICtrlListView_SetImageList($hListView, $hImage, 1) ; msgbox(4160,"Total images in List",_GUIImageList_GetImageCount($hImage)) MsgBox(4160, "Information", "Adding imagelist two new lv item and images") _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF8040, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x408080, 16, 16)) _GUICtrlListView_AddItem($hListView, "New Item 4", 2) _GUICtrlListView_AddItem($hListView, "New Item 5", 3) _GUICtrlListView_SetImageList($hListView, $hImage, 1) MsgBox(64, "Information", "Added items to the listview using the new image list" & @CRLF & "Now resetting the image used for Item 1-3 to use the correct image in the new image list.") _GUICtrlListView_SetItemImage($hListView, 0, 1) ; Resets which image Item 1 uses for it's image in the new image list. _GUICtrlListView_SetItemImage($hListView, 1, 1) ; Resets which image Item 2 uses for it's image in the new image list. _GUICtrlListView_SetItemImage($hListView, 2, 1) ; Resets which image Item 3 uses for it's image in the new image list. ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Edited October 12, 2012 by Tin2tin DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 12, 2012 Share Posted October 12, 2012 You might want to check these lines: _GUICtrlListView_SetItemImage($hListView, 0, 1) ; Resets which image Item 1 uses for it's image in the new image list. _GUICtrlListView_SetItemImage($hListView, 1, 1) ; Resets which image Item 2 uses for it's image in the new image list. _GUICtrlListView_SetItemImage($hListView, 2, 1) ; Resets which image Item 3 uses for it's image in the new image list. They all point to the same image in the image list. It should probably be 0, 1, and 2 instead of all 1s. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tin2tin Posted October 12, 2012 Author Share Posted October 12, 2012 Sorry. I didn't understand that function before posting. Now it seems like I've solved my problems in my main script - so thank you very much. :-) DVD slideshow GUI Link to comment Share on other sites More sharing options...
BrewManNH Posted October 12, 2012 Share Posted October 12, 2012 Glad I could help, and I learned some new information myself while researching, so it's a win. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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