Jump to content

GUIListViewEx.au3 | Clear the entire list with one button?


Kovacic
 Share

Go to solution Solved by Melba23,

Recommended Posts

Kovacic,

All that snippet tells me is that it should not work. ;)

_GUIListViewEx_Close($resultlist)                 ; Should be the index returned from _GUIListViewEx_Init
_GUICtrlListView_DeleteAllItems($resultlist)      ; Should be the handle/ControlID returned by GUICtrlCreateListView/_GUICrtlListView_Create
_GUIListViewEx_Init($resultlist, "", 0, 0x00FF00) ; Here you need to store the new index retuned by the function...
_GUIListViewEx_SetActive($resultlist)             ; ...which you then use here
So using the same variable for all of these is very unlikely to give you what you think you should get. Please ask if you do not understand my comments - they are pretty fundamental to the script working correctly. :)

 

 

I think I just heard a popping noise come from my neocortex lol... 

So everytime I clear the results list, I need to assign it a new variable?

I apologize for my newness ;)

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

  • Moderators

Kovacic,

When you create the ListView the function you use returns a value:

 

- If you used GUICtrlCreateListView it is a ControlID - an internal AutoIt index to the control.

- If you used _GUICtrlListView_Create then it is a handle - a Windows ID for a control.

Whichever value is returned is the one you normally use in subsequent native commands / GUIListView UDF functions to control the ListView.

However, if you want to use my GUIListViewEx UDF you need to use yet another index when using the UDF functions - the one returned by _GUIListViewEx_Init. Sounds complicated I know but in reality it is very simple. :)

You have to identify the ListView in question to AutoIt so that it knows which one you are asking it to action. Look at the example script I posted earlier today:

; This is a native-created ListView and so it returns a ControlID - note the $c prefix I used

$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)

; This is a GUIListView.au3 create dListView and so it returns a handle - note the $h prefix I used

$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))

; These are calls to my GUIListViewEx UDF and they return index numbers to use with UDF functions - note the $i prefix I used

$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2 + 8, "0;2")
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4 + 8 + 16)
So with native functions (ones without an underscore) you use the ControlID; with the _GUIListView_* functions you use the handle; and with the _GUIListViewEx_* functions you use the index. Following so far? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Kovacic,

Excellent news! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Well, I read too later this topic...

And trasform a original function to delete a listView, the method showed here is simple, and small.

But, only share my mod:

; #FUNCTION# =========================================================================================================
; Name...........: _GUIListViewEx_DeleteAll
; Description ...: Deletes all item(s) in active ListView
; Syntax.........: _GUIListViewEx_DeleteAll()
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: Success: Array of active ListView with count in [0] element
;                  Failure: Returns "" and sets @error as follows:
; Author ........: Melba23
; Modified ......: Detefon
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIListViewEx_DeleteAll()

    ; Set data for active ListView
    Local $iArray_Index = $aGLVEx_Data[0][1]
    ; If no ListView active then return
    If $iArray_Index = 0 Then Return SetError(1, 0, "")

    ; Load active ListView details
    $hGLVEx_SrcHandle = $aGLVEx_Data[$iArray_Index][0]
    $cGLVEx_SrcID = $aGLVEx_Data[$iArray_Index][1]

    ; Copy array for manipulation
    $aGLVEx_SrcArray = $aGLVEx_Data[$iArray_Index][2]

    Local $aCheck_Array = $aGLVEx_SrcArray

    For $ii = 1 To UBound($aGLVEx_SrcArray, 1) - 1
        _GUIListViewEx_Array_Delete($aGLVEx_SrcArray, $ii)
        _GUIListViewEx_Array_Delete($aCheck_Array, $ii)
        $aGLVEx_SrcArray[0][0] = UBound($aGLVEx_SrcArray, 1) - 1
    Next
    _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $cGLVEx_SrcID, $aGLVEx_SrcArray, $aCheck_Array, $iArray_Index)
    $aGLVEx_Data[$iArray_Index][2] = $aGLVEx_SrcArray
    $aGLVEx_SrcArray = 0
    Return _GUIListViewEx_ReturnArray($iArray_Index)

EndFunc   ;==>_GUIListViewEx_DeleteAll
Edited by detefon

Visit my repository

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...