GaryFrost Posted November 20, 2007 Share Posted November 20, 2007 (edited) Need AutoIt v3.2.10.0 to run this.It will work with the built-in ListView or the UDF created ListView.The user would only need 2 lines of code._GUICtrlListView_RegisterSimpleSort($hListView)_GUICtrlListView_UnRegisterSimpleSort($hListView)And also be able to remove it's dependency of Array.au3expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Opt('MustDeclareVars', 1) Global $aListViewSortInfo; this variables will go in the GuiListView.au3 _Example_Internal() _Example_External() _Example_InternalMultiple() _Example_ExternalMultiple() _Example_Both() Func _Example_Internal() Local $hListView, $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES) GUICreate("(Internal) ListView Sort", 300, 200) $hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) GUICtrlCreateListViewItem("ABC|000666|10.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("DEF|444|11.05.2005", $hListView) GUICtrlSetImage(-1, "shell32.dll", 12) GUICtrlCreateListViewItem("CDE|555|12.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 3) _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) GUISetState() _GUICtrlListView_RegisterSimpleSort($hListView, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlListView_UnRegisterSimpleSort($hListView) GUIDelete() EndFunc ;==>_Example_Internal Func _Example_External() Local $hGUI, $hImage, $hListView, $aIcons[3] = [0, 3, 6] Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER) $hGUI = GUICreate("(External) ListView Sort", 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) ; Load images $hImage = _GUIImageList_Create(18, 18, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _AddRow($hListView, "ABC|000666|10.05.2004", $aIcons) _AddRow($hListView, "DEF|444|11.05.2005", $aIcons, 1) _AddRow($hListView, "CDE|555|12.05.2004", $aIcons, 2) GUISetState() _GUICtrlListView_RegisterSimpleSort($hListView) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlListView_UnRegisterSimpleSort($hListView) GUIDelete() EndFunc ;==>_Example_External Func _Example_InternalMultiple() Local $hListView, $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES) Local $hGUI, $hGUI2, $hListView2 $hGUI = GUICreate("(Internal) ListView Sort Treat Numbers as Strings", 300, 200, 100) $hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) GUICtrlCreateListViewItem("ABC|000666|10.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("DEF|444|11.05.2005", $hListView) GUICtrlSetImage(-1, "shell32.dll", 12) GUICtrlCreateListViewItem("CDE|555|12.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 3) _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) $hGUI2 = GUICreate("(Internal) ListView Sort Treat Numbers as Numbers", 300, 200, 400) $hListView2 = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView2, $iExListViewStyle) GUICtrlCreateListViewItem("ABC|000666|10.05.2004", $hListView2) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("DEF|444|11.05.2005", $hListView2) GUICtrlSetImage(-1, "shell32.dll", 12) GUICtrlCreateListViewItem("CDE|555|12.05.2004", $hListView2) GUICtrlSetImage(-1, "shell32.dll", 3) _GUICtrlListView_SetColumnWidth($hListView2, 0, $LVSCW_AUTOSIZE) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI2) _GUICtrlListView_RegisterSimpleSort($hListView, False) _GUICtrlListView_RegisterSimpleSort($hListView2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlListView_UnRegisterSimpleSort($hListView) _GUICtrlListView_UnRegisterSimpleSort($hListView2) GUIDelete($hGUI) GUIDelete($hGUI2) EndFunc ;==>_Example_Internal Func _Example_ExternalMultiple() Local $hGUI, $hImage, $hListView, $aIcons[3] = [0, 3, 6] Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER) Local $hGUI2, $hListView2 $hGUI = GUICreate("(External) ListView Sort Treat Numbers as Strings", 300, 200, 100) $hListView = _GUICtrlListView_Create($hGUI, "Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) ; Load images $hImage = _GUIImageList_Create(18, 18, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _AddRow($hListView, "ABC|000666|10.05.2004", $aIcons) _AddRow($hListView, "DEF|444|11.05.2005", $aIcons, 1) _AddRow($hListView, "CDE|555|12.05.2004", $aIcons, 2) $hGUI2 = GUICreate("(External) ListView Sort Treat Numbers as Numbers", 300, 200, 400) $hListView2 = _GUICtrlListView_Create($hGUI2, "Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView2, $iExListViewStyle) _GUICtrlListView_SetImageList($hListView2, $hImage, 1) _AddRow($hListView2, "ABC|000666|10.05.2004", $aIcons) _AddRow($hListView2, "DEF|444|11.05.2005", $aIcons, 1) _AddRow($hListView2, "CDE|555|12.05.2004", $aIcons, 2) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI2) _GUICtrlListView_RegisterSimpleSort($hListView, False) _GUICtrlListView_RegisterSimpleSort($hListView2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlListView_UnRegisterSimpleSort($hListView) _GUICtrlListView_UnRegisterSimpleSort($hListView2) GUIDelete($hGUI) GUIDelete($hGUI2) EndFunc ;==>_Example_External Func _Example_Both() Local $hGUI, $hImage, $hListView, $aIcons[3] = [0, 3, 6] Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER) Local $hGUI2, $hListView2 $hGUI = GUICreate("(Internal) ListView Sort Treat Numbers as Strings", 300, 200, 100) $hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle) GUICtrlCreateListViewItem("ABC|000666|10.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("DEF|444|11.05.2005", $hListView) GUICtrlSetImage(-1, "shell32.dll", 12) GUICtrlCreateListViewItem("CDE|555|12.05.2004", $hListView) GUICtrlSetImage(-1, "shell32.dll", 3) _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) $hGUI2 = GUICreate("(External) ListView Sort Treat Numbers as Numbers", 300, 200, 400) $hListView2 = _GUICtrlListView_Create($hGUI2, "Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle) _GUICtrlListView_SetExtendedListViewStyle($hListView2, $iExListViewStyle) ; Load images $hImage = _GUIImageList_Create(18, 18, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11) _GUICtrlListView_SetImageList($hListView2, $hImage, 1) _AddRow($hListView2, "ABC|000666|10.05.2004", $aIcons) _AddRow($hListView2, "DEF|444|11.05.2005", $aIcons, 1) _AddRow($hListView2, "CDE|555|12.05.2004", $aIcons, 2) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI2) _GUICtrlListView_RegisterSimpleSort($hListView, False) _GUICtrlListView_RegisterSimpleSort($hListView2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlListView_UnRegisterSimpleSort($hListView) _GUICtrlListView_UnRegisterSimpleSort($hListView2) GUIDelete($hGUI) GUIDelete($hGUI2) EndFunc ;==>_Example_External Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0) Local $aItem = StringSplit($sItem, "|") Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus) _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER) For $x = 2 To $aItem[0] _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus) _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE) Next EndFunc ;==>_AddRow ;======================================================================= ; from here down would be for the include file ;======================================================================= ; #FUNCTION# =========================================================== ; Name...........: _GUICtrlListView_RegisterSimpleSort ; Description ...: Register the Simple Sort callback function ; Syntax.........: _GUICtrlListView_RegisterSimpleSort($hWnd[, $fNumbers = True]) ; Parameters ....: $hWnd - Handle of the control ; $fNumbers - Treat number strings as numbers ; Return values .: Success - True ; Failure - False ; Author ........: Gary Frost (gafrost) ; Modified.......: ; Remarks .......: For each call to _GUICtrlListView_RegisterSimpleSort there must be a call ; to _GUICtrlListView_UnRegisterSimpleSort when done (before exit) ; Related .......: _GUICtrlListView_UnRegisterSimpleSort ; Link ..........; ; Example .......; Yes ; ======================================================================== Func _GUICtrlListView_RegisterSimpleSort($hWnd, $fNumbers = True) If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd) Local $iIndex If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If IsArray($aListViewSortInfo) Then ReDim $aListViewSortInfo[UBound($aListViewSortInfo) + 1][9] Else Global $aListViewSortInfo[2][9] EndIf $aListViewSortInfo[0][0] = UBound($aListViewSortInfo) - 1 $iIndex = UBound($aListViewSortInfo) - 1 $aListViewSortInfo[$iIndex][1] = $hWnd ; Handle/ID of listview If $aListViewSortInfo[0][0] = 1 Then _ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_UDF_INTERNAL_LV_SORT") $aListViewSortInfo[$iIndex][2] = _ DLLCallbackRegister("_GUICtrlListView_Sort", "int", "int;int;hwnd") ; Handle of callback $aListViewSortInfo[$iIndex][3] = -1 ; $nColumn $aListViewSortInfo[$iIndex][4] = -1 ; nCurCol $aListViewSortInfo[$iIndex][5] = 1 ; $nSortDir $aListViewSortInfo[$iIndex][6] = -1 ; $nCol $aListViewSortInfo[$iIndex][7] = 0 ; $bSet $aListViewSortInfo[$iIndex][8] = $fNumbers ; Treat as numbers? Return $aListViewSortInfo[$iIndex][2] <> 0 EndFunc ;==>_GUICtrlListView_RegisterSimpleSort ; #FUNCTION# ======================================================================== ; Name...........: _GUICtrlListView_UnRegisterSimpleSort ; Description ...: UnRegister the Simple Sort callback function ; Syntax.........: _GUICtrlListView_UnRegisterSimpleSort($hWnd) ; Parameters ....: $hWnd - Handle of the control ; Return values .: None ; Author ........: Gary Frost (gafrost) ; Modified.......: ; Remarks .......: Removes the element from the array ; Related .......: _GUICtrlListView_RegisterSimpleSort ; Link ..........; ; Example .......; Yes ; ================================================================================================= Func _GUICtrlListView_UnRegisterSimpleSort($hWnd) If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) For $x = 1 To $aListViewSortInfo[0][0] If $hWnd = $aListViewSortInfo[$x][1] Then DllCallbackFree($aListViewSortInfo[$x][2]) _GUICtrlListView_ArrayDelete($aListViewSortInfo, $x) $aListViewSortInfo[0][0] -= 1 ExitLoop EndIf Next EndFunc ;==>_GUICtrlListView_UnRegisterSimpleSort ; #INTERNAL_USE_ONLY#============================================================================== ; Name...........: _GUICtrlListView_SortItems ; Description ...: For use with WM_NOTIFY_UDF_INTERNAL_LV_SORT ; Syntax.........: _GUICtrlListView_SortItems($hWnd, $iCol) ; Parameters ....: $hWnd - Handle of the control ; $iCol - Column clicked ; Return values .: None ; Author ........: Gary Frost (gafrost) ; Modified.......: ; Remarks .......: For Internal Use Only ; Related .......: WM_NOTIFY_UDF_INTERNAL_LV_SORT ; Link ..........; ; Example .......; ; ================================================================================================= Func _GUICtrlListView_SortItems($hWnd, $iCol) Local $iResult, $iIndex, $pFunction For $x = 1 To $aListViewSortInfo[0][0] If $hWnd = $aListViewSortInfo[$x][1] Then $iIndex = $x ExitLoop EndIf Next $pFunction = DllCallbackGetPtr($aListViewSortInfo[$iIndex][2]) ; get pointer to call back $aListViewSortInfo[$iIndex][3] = $iCol ; $nColumn = column clicked $aListViewSortInfo[$iIndex][7] = 0 ; $bSet $aListViewSortInfo[$iIndex][4] = $aListViewSortInfo[$iIndex][6] ; nCurCol = $nCol $iResult = _SendMessage($hWnd, $LVM_SORTITEMS, $hWnd, $pFunction, 0, "hwnd", "ptr") Return $iResult <> 0 EndFunc ;==>_GUICtrlListView_SortItems ; #INTERNAL_USE_ONLY#============================================================================== ; Name...........: _GUICtrlListView_Sort ; Description ...: Our sorting callback funtion ; Syntax.........: _GUICtrlListView_Sort($nItem1, $nItem2, $hWnd) ; Parameters ....: $nItem1 - Param of 1st item ; $nItem2 - Param of 2nd item ; $hWnd - Handle of the control ; Return values .: None ; Author ........: Gary Frost (gafrost) ; Modified.......: ; Remarks .......: For Internal Use Only ; Related .......: ; Link ..........; ; Example .......; ; ================================================================================================= Func _GUICtrlListView_Sort($nItem1, $nItem2, $hWnd) Local $iIndex, $tInfo, $val1, $val2, $nResult $tInfo = DllStructCreate($tagLVFINDINFO) DllStructSetData($tInfo, "Flags", $LVFI_PARAM) For $x = 1 To $aListViewSortInfo[0][0] If $hWnd = $aListViewSortInfo[$x][1] Then $iIndex = $x ExitLoop EndIf Next ; Switch the sorting direction If $aListViewSortInfo[$iIndex][3] = $aListViewSortInfo[$iIndex][4] Then ; $nColumn = nCurCol ? If Not $aListViewSortInfo[$iIndex][7] Then ; $bSet $aListViewSortInfo[$iIndex][5] = $aListViewSortInfo[$iIndex][5] * - 1 ; $nSortDir $aListViewSortInfo[$iIndex][7] = 1 ; $bSet EndIf Else $aListViewSortInfo[$iIndex][5] = 1 ; $bSet EndIf $aListViewSortInfo[$iIndex][6] = $aListViewSortInfo[$iIndex][3] ; $nCol = $nColumn DllStructSetData($tInfo, "Param", $nItem1) $val1 = _GUICtrlListView_FindItem($hWnd, -1, $tInfo) DllStructSetData($tInfo, "Param", $nItem2) $val2 = _GUICtrlListView_FindItem($hWnd, -1, $tInfo) $val1 = _GUICtrlListView_GetItemText($hWnd, $val1, $aListViewSortInfo[$iIndex][3]) $val2 = _GUICtrlListView_GetItemText($hWnd, $val2, $aListViewSortInfo[$iIndex][3]) If $aListViewSortInfo[$iIndex][8] Then ; Treat As Number If (StringIsFloat($val1) Or StringIsInt($val1)) Then $val1 = Number($val1) If (StringIsFloat($val2) Or StringIsInt($val2)) Then $val2 = Number($val2) EndIf $nResult = 0 ; No change of item1 and item2 positions If $val1 < $val2 Then $nResult = -1 ; Put item2 before item1 ElseIf $val1 > $val2 Then $nResult = 1 ; Put item2 behind item1 EndIf $nResult = $nResult * $aListViewSortInfo[$iIndex][5] ; $nSortDir Return $nResult EndFunc ;==>_GUICtrlListView_Sort ; #INTERNAL_USE_ONLY#============================================================================== ; Name...........: WM_NOTIFY_UDF_INTERNAL_LV_SORT ; Description ...: Notification event for Column Click Events to call the Sort message ; Syntax.........: WM_NOTIFY_UDF_INTERNAL_LV_SORT($hWnd, $iMsg, $iwParam, $ilParam) ; Parameters ....: $hWnd - Handle of the control ; $iMsg - Message ; $iwParam - wParam ; $ilParam - lParam ; Return values .: $GUI_RUNDEFMSG ; Author ........: Gary Frost (gafrost) ; Modified.......: ; Remarks .......: For Internal Use Only ; Related .......: _GUICtrlListView_SortItems ; Link ..........; ; Example .......; ; ================================================================================================= Func WM_NOTIFY_UDF_INTERNAL_LV_SORT($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iCode, $tNMHDR, $iIndex $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $x = 1 To $aListViewSortInfo[0][0] If $hWndFrom = $aListViewSortInfo[$x][1] Then $iIndex = $x ExitLoop EndIf Next Switch $hWndFrom Case $aListViewSortInfo[$iIndex][1] Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem")) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY_UDF_INTERNAL_LV_SORT ; #INTERNAL_USE_ONLY#============================================================================== ; Name...........: _GUICtrlListView_ArrayDelete ; Description ...: Deletes the specified element from the given array, returning the adjusted array. ; Syntax.........: _GUICtrlListView_ArrayDelete(ByRef $avArray, $iElement) ; Parameters ....: $avArray - The array from which an element is to be deleted ; $iElement - The index of the element to be deleted ; Return values .: Success - Returns 1 and the original Array is updated ; Failure - Returns 0 and the original Array ; Author ........: Cephas <cephas at clergy dot net> ; Modified.......: Array is passed via Byref - Jos van der zande, for exclusive use with listview sort - GaryFrost ; Remarks .......: For Internal Use Only ; Related .......: ; Link ..........; ; Example .......; ; ================================================================================================= Func _GUICtrlListView_ArrayDelete(ByRef $avArray, $iElement) Local $iCntr = 0, $iUpper = 0 If (Not IsArray($avArray)) Then SetError(1) Return "" EndIf ; We have to define this here so that we're sure that $avArray is an array ; before we get it's size. $iUpper = UBound($avArray) ; Size of original array ; If the array is only 1 element in size then we can't delete the 1 element. If $iUpper = 1 Then SetError(2) Return "" EndIf Local $avNewArray[$iUpper - 1][9] $avNewArray[0][0] = $avArray[0][0] If $iElement < 0 Then $iElement = 0 EndIf If $iElement > ($iUpper - 1) Then $iElement = ($iUpper - 1) EndIf If $iElement > 0 Then For $iCntr = 0 To $iElement - 1 $avNewArray[$iCntr][1] = $avArray[$iCntr][1] $avNewArray[$iCntr][2] = $avArray[$iCntr][2] $avNewArray[$iCntr][3] = $avArray[$iCntr][3] $avNewArray[$iCntr][4] = $avArray[$iCntr][4] $avNewArray[$iCntr][5] = $avArray[$iCntr][5] $avNewArray[$iCntr][6] = $avArray[$iCntr][6] $avNewArray[$iCntr][7] = $avArray[$iCntr][7] $avNewArray[$iCntr][8] = $avArray[$iCntr][8] Next EndIf If $iElement < ($iUpper - 1) Then For $iCntr = ($iElement + 1) To ($iUpper - 1) $avNewArray[$iCntr - 1][1] = $avArray[$iCntr][1] $avNewArray[$iCntr - 1][2] = $avArray[$iCntr][2] $avNewArray[$iCntr - 1][3] = $avArray[$iCntr][3] $avNewArray[$iCntr - 1][4] = $avArray[$iCntr][4] $avNewArray[$iCntr - 1][5] = $avArray[$iCntr][5] $avNewArray[$iCntr - 1][6] = $avArray[$iCntr][6] $avNewArray[$iCntr - 1][7] = $avArray[$iCntr][7] $avNewArray[$iCntr - 1][8] = $avArray[$iCntr][8] Next EndIf $avArray = $avNewArray SetError(0) Return 1 EndFunc ;==>_GUICtrlListView_ArrayDelete Edited November 25, 2007 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted November 24, 2007 Author Share Posted November 24, 2007 (edited) Moved to Example scripts to see what kind response I get to this. Edited November 24, 2007 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ptrex Posted November 24, 2007 Share Posted November 24, 2007 @GaryFrost When I try to run it I get a lot of undeclared vars, like this " WARNING: $LVM_SORTITEMS: possibly used before declaration." Are there any dependencies for running it ? Thanks ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
GaryFrost Posted November 24, 2007 Author Share Posted November 24, 2007 (edited) @GaryFrostWhen I try to run it I get a lot of undeclared vars, like this " WARNING: $LVM_SORTITEMS: possibly used before declaration."Are there any dependencies for running it ?ThanksptrexDo you have "AutoIt v3.2.10.0"? Edited November 25, 2007 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ValeryVal Posted November 25, 2007 Share Posted November 25, 2007 When I try to run it I get a lot of undeclared vars, like this " WARNING: $LVM_SORTITEMS: possibly used before declaration." Add this line Global $LVM_SORTITEMS = $LVM_FIRST + 48 after line #include <GuiImageList.au3> The point of world view Link to comment Share on other sites More sharing options...
GaryFrost Posted November 25, 2007 Author Share Posted November 25, 2007 Add this line Global $LVM_SORTITEMS = $LVM_FIRST + 48 after line #include <GuiImageList.au3> No need to add that line. Its in the include SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ValeryVal Posted November 25, 2007 Share Posted November 25, 2007 autoit-v3.2.9.14.exe doesn't know about it, and it is a reason of question, I think. thanx for your code... The point of world view Link to comment Share on other sites More sharing options...
GaryFrost Posted November 25, 2007 Author Share Posted November 25, 2007 autoit-v3.2.9.14.exe doesn't know about it, and it is a reason of question, I think.thanx for your code... That's why I stated in the first line of the 1st post what version was needed. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ValeryVal Posted November 25, 2007 Share Posted November 25, 2007 Understood. But he (like me) hasn't wish to make whole setup and preferes the next version. It's simply to add character ";" after upgrade instead of new messages here, I think The point of world view Link to comment Share on other sites More sharing options...
GaryFrost Posted November 25, 2007 Author Share Posted November 25, 2007 Understood. But he (like me) hasn't wish to make whole setup and preferes the next version.It's simply to add character ";" after upgrade instead of new messages here, I think3.2.10.0 has been released, so the constant is in the next version SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted November 25, 2007 Author Share Posted November 25, 2007 Updated script in 1st post, now works with multiple listviews correctly, added examples to show with using multiple listviews. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ValeryVal Posted November 25, 2007 Share Posted November 25, 2007 3.2.10.0 has been released, so the constant is in the next versionHe (like me) preferes the time of new version release to use previos version. Is this other order in US? We will love president Putin when other president will come to Russia. Other words. US citizen like Clinton when Bush is ruling in USA. This is the law of the human live, I think. The point of world view Link to comment Share on other sites More sharing options...
GaryFrost Posted November 25, 2007 Author Share Posted November 25, 2007 He (like me) preferes the time of new version release to use previos version. Is this other order in US? We will love president Putin when other president will come to Russia. Other words. US citizen like Clinton when Bush is ruling in USA. This is the law of the human live, I think. I understand what your saying.What I'm saying is:Unless the user states they don't want to go to the latest version, then there is no reason for them to have to delcare variables. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Zedna Posted November 25, 2007 Share Posted November 25, 2007 (edited) This looks good Gary. Thanks. I'm looking forward to time when I will move from 3.2.8 to 3.2.10 Edited November 25, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ptrex Posted November 26, 2007 Share Posted November 26, 2007 @GaryFrost Sorry for not noticing the Version requirements in the beginning. I do an update soon and give it a try. Thanks ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New 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