Melba23

GUIListViewEx - BugFix Version 25 Sep 17

241 posts in this topic

#41 ·  Posted (edited)

Sturmi,

Quote

sorry for wasting your time!

Not at all - I am always happy to look at a problem with any of my code. And in this case you appear to have found a really good one! I will look into it and let you know what I find.

M23

Edit: Solved it! You were overwriting the standard extended styles, one of which is $LVS_EX_FULLROWSELECT and without which you cannot detect clicks on anything other then the first column. So create your ListView like this:

$List1 = GUICtrlCreateListView("Data|Your Info", 8, 8, 241, 357)
_GUICtrlListView_SetExtendedListViewStyle($List1, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE))

Note the use of _GUICtrlListView_SetExtendedListViewStyle - always best to use that as there can be confusion between certain $LVS_EX_* and $WS_EX_* styles if you set them in the GUICtrlCreateListView command.

Edited by Melba23
Format
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites



thanks a ton @Melba23. works now perfect, I will read through your udf later too but is it possible to get a button in one cell and when as example cell 2 is filled out with specific value cell 3 gets disabled ? thats my last question

 

thanks very much

Share this post


Link to post
Share on other sites

Sturmi,

Quote

is it possible to get a button in one cell

No, you can have either a text input, a combo or a datetime picker.  Why do you want a button?

As to the other question - define "cell 2", "cell 3" and "disabled".

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I need it for choosing a Folder Directory.

Share this post


Link to post
Share on other sites

Was a fun couple of hours, was easier than I thought but attacked it from the wrong angle. And a big UDF is like a maze for me. The change to Case 3 makes Tab move the edit to the next row after the last column. Until the last row, where it just loops back to the first column. Can't believe such a simple thing took me so long, I need to get better at this. Time for bed.

Case 0x09, 0x27 ; TAB or right arrow
                    While 1
                        If $iEditCol <> 0 Then
                            ; Set next column
                            $aLocation[1] += 1
                            ; Check column exists
                            If $aLocation[1] = _GUICtrlListView_GetColumnCount($hGLVEx_Editing) Then
                                ; Does not exist so check required action
                                Switch $iEditCol
                                    Case 1
                                        ; Exit edit process
                                        ExitLoop 2
                                    Case 2
                                        ; Stay on same location
                                        $aLocation[1] -= 1
                                        ExitLoop
                                    Case 3 ;; yay it works
                                        If $aLocation[0] + 1 < $aGLVEx_SrcArray[0][0] Then
                                            $aLocation[0] += 1
                                        EndIf
                                        ; Loop
                                        $aLocation[1] = 0
                                EndSwitch
                            EndIf

 

1 person likes this

Share this post


Link to post
Share on other sites

Melba23,

 

Seems one of my other text controls was overlapping the list view.  Adjusted it and its now behaving itself.  Thanks for your earlier reply.

 

 

Share this post


Link to post
Share on other sites

bourny,

No problem - glad you got it working.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#48 ·  Posted (edited)

Sturmi,

Your recent posts got me thinking - so here is a Beta version of the UDF which has the following additions:

  • You can disable header resizing.
  • You can "custom" edit a column using a user-defined function within your script, so you can easily select a folder as you required.

Here is an example script:

<snip>

And here is the Beta UDF to use with it: <snip> . Note that you now need to supply a 4-row array when using _GUIListViewEx_LoadHdrData - this is a script-breaking change from the current version so be careful if you test the Beta code on any of your own scripts.

Let me know what you think - and comments from others very welcome too.

M23

Edited by Melba23
Removed Beta code

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Nice addition Melba, adds so much more flexibility. 

Thanks.

Share this post


Link to post
Share on other sites

#50 ·  Posted (edited)

Hi all,

A really good day: won my golf match this morning, flew 3 times this afternoon and this evening coded another functionality for this UDF - you can now define a user sort function to use when ordering the ListView columns.

Here is an example script which shows yesterday's header resize disable and user function for edit, plus today's user function for sort functionalities - look at the difference when sorting column 2 compared to the others:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Global $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Beta Example", 500, 360)

; Create ListView
$cListView = GUICtrlCreateListView("Tom|Dick|Harry", 10, 10, 480, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView,$LVS_EX_FULLROWSELECT )
_GUICtrlListView_SetColumnWidth($cListView, 0, 150)
_GUICtrlListView_SetColumnWidth($cListView, 1, 150)
_GUICtrlListView_SetColumnWidth($cListView, 2, 150)

; Create array and fill Left listview
Global $aLV_List[15]
For $i = 0 To 14
    $aLV_List[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    GUICtrlCreateListViewItem("Tom " & $i & "|Dick " & $i & "|Harry " & $i, $cListView)
Next

; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text
$iLV_Index = _GUIListViewEx_Init($cListView, $aLV_List, 0, Default, Default, 1)
; Column 0 & 2 editable using user function
_GUIListViewEx_SetEditStatus($iLV_Index, "0;2", 9, _UserFunction) ; Here we set both columns to use the user-defined function below <<<<<<<<<<<<<<<<<<<<<<<<<<<

; Set header data for edit - Col 0 uses an edit and cannot be resized
;                            Col 1 is not editable as column itself is not editable and can be resized
;                            Col 2 uses a combo and can be resized
Local $aHdrData[][] =  [["", "", ""], _
                        ["", "", ""], _
                        ["", "", "New 1|New 2|New 3"], _
                        [1,  0,  0]]                                   ; Here is where the column resizing is set <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iRet = _GUIListViewEx_LoadHdrData($iLV_Index, $aHdrData)

; This function initiates tooltips when items in col 0 are clicked as any path is likely to be too wide to fully display
_GUIListViewEx_ToolTipInit($iLV_Index, "0")

; Use user sort function when sorting <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iRet = _GUIListViewEx_UserSort(_UserSortFunction)

$cDisplay_Button = GUICtrlCreateButton("Show content", 10, 320, 230, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 260, 320, 230, 30)

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit

        Case $cDisplay_Button

            $aLV_List = _GUIListViewEx_ReturnArray($iLV_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf

    EndSwitch

    ; This function must be in the idle loop to anable editing of any kind
    $vRet = _GUIListViewEx_EditOnClick()

    ; Save error value
    Local $iError = @error

    ; If column edited by user function then $vret reflect return values from that function
    ; If column editable in modes 1-3 (internal UDF editing) then an array of edited items returned
    ; If no edits occurred then function returns empty string - so check array exists before viewing
    If IsArray($vRet) Then
        ; Uncomment to see returned array
        ;_ArrayDisplay($vRet, @error)
    ElseIf $vRet <> "" Then
        ; Uncomment to see returned values
        ;ConsoleWrite($vRet & " - " & $iError & " - " & @extended & @CRLF)
    EndIf

    ; This function enables the tooltips when cols 0 & 2 are clicked as the path is likely to be too wide to fully display
    _GUIListViewEx_ToolTipShow()

WEnd

; User function must take 4 parameters - no more, no less
; ListView handle, ListView UDF index, Row clicked, Column clicked
Func _UserFunction($hLV, $iIndex, $iRow, $iCol)

    ; Then depending on the column clicked
    Switch $iCol
        Case 0 ; Col 0 accepts an .au3 file
            $sRet = FileOpenDialog("Choose a file", "", "Files(*.au3)", 0, "", $hLV)
            If $sRet Then
                $aContent = _GUIListViewEx_ChangeItem($iIndex, $iRow, $iCol, $sRet)
            EndIf
        Case 2 ; Col 2 accepts a folder
            $sRet = FileSelectFolder("Choose a folder", "", 0, "", $hLV)
            If $sRet Then
                $aContent = _GUIListViewEx_ChangeItem($iIndex, $iRow, $iCol, $sRet)
            EndIf
    EndSwitch

    Return 1

EndFunc

; User sort function must take 5 parameters - no more no less - which match those used by _ArraySort
; ByRef array, Descending variable, Start (usually 1), End (usually 0, so need to convert to max index), Column to sort
Func _UserSortFunction(ByRef $aArray, $vDescending, $iStart, $iEnd, $iCol)

    Switch $iCol
        Case 0, 1 ; Standard sort for columns 0 & 1
            _ArraySort($aArray, $vDescending, $iStart, $iEnd, $iCol)
        Case 2 ; This column is sorted numerically on the numeric part of the content
            If $iEnd = 0 Then $iEnd = UBound($aArray) - 1
            _ArrayColInsert($aArray, 0)
            For $i = $iStart To $iEnd
                $aArray[$i][0] = Number(StringRegExpReplace($aArray[$i][$iCol + 1], "^.\D+(\d+)$", "$1"))
            Next
            _ArraySort($aArray, $vDescending, $iStart, $iEnd, 0)
            _ArrayColDelete($aArray, 0)
    EndSwitch

EndFunc

And here is the Beta UDF required to run it:  

I also fixed a couple of small bugs in the previous Beta code while I was at it......  All comments welcome.

M23

Edit: Added an "auto dropdown" option when using combos to edit - change the _SetEditStatus lines in the example to this to see the effect:

_GUIListViewEx_SetEditStatus($iLV_Index, "0", 2, "1|2|3", 0)     ; Normal combo
_GUIListViewEx_SetEditStatus($iLV_Index, "1", 2, "1|2|3", 1)     ; Read only combo
_GUIListViewEx_SetEditStatus($iLV_Index, "2", 2, "1|2|3", 0 + 2) ; Normal combo with auto dropdown

 

Edited by Melba23
Deleted Beta code
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Congrats on the golf; all that by 6:30pm, you really work quick.

The examples work fine, very useful features. I can use the edit function to transfer folders and files to other pc's on the network; with the list view field containing the network address of the pc that sends the request. And the sorting is working perfect for me as far as I can tell. Lovely jubbly.

When enabling arraydisplay in the loop, it misbehaves after the first edit. It runs as soon as you try to make the next edit, instead of after confirming/abandoning. Although when putting the below code in the loop, it works as expected ie. does the IniDelete and IniWrite after the edit has been confirmed. Very strange.

If IsArray($aRet) Then
    $iItem = _GUICtrlListView_GetSelectedIndices($hListView_Right)
    $aItem = _GUICtrlListView_GetItemTextArray($hListView_Right, $iItem)
    If $aRet[UBound($aRet) - 1][2] <> "" Then IniDelete("test.ini", "test", $aRet[1][2])
    IniWrite("test.ini", "test", $aItem[1], $aItem[2] & "|" & $aItem[3])
EndIf

 

Share this post


Link to post
Share on other sites

Inpho,

I like to keep busy - and it is all fun for those of us enjoying retirement!!!

I see the problem you mention - very peculiar. Looking into that will be tomorrow's item to keep the "little grey cells" active.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Inpho,

That was a fun few hours, but I have found the problem.

Under certain unspecified circumstances the internal __GUIListViewEx_EditProcess function was returning an array even when no edits had taken place, rather then the expected empty string. I have therefore amended the wrapping _GUIListViewEx_EditOnClick & _GUIListViewEx_EditItem functions so that they check the return from the internal function and, should this "empty" array (it has a 0 count element) appear, replace it with the expected empty string.

I fully acknowledge that this is dealing with the symptom rather then the cause, but after a long time trying to determine just when this rather complex internal function decided to return this "empty" array I felt that it was by far the easiest option!

I have reloaded the Beta code above, so could you (and any others reading) please check it out at your convenience.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#54 ·  Posted (edited)

Nice addition Melba, adds so much more flexibility. 

I had also noticed the empty array returned from edit process especially if an edit was begun, but no changes made.

I added this little code to deal with both...

$aLV_EIP_RET = _GUIListViewEx_EditOnClick($LV_EDIT_MODE)
        If UBound($aLV_EIP_RET) > 1 Then
            ; check Col & New value exist
            For $r = UBound($aLV_EIP_RET) - 1 To 1 Step -1
                If Not ($aLV_EIP_RET[$r][1] And $aLV_EIP_RET[$r][3]) Then ; edit was begun but no changes made
                    _ArrayDelete($aLV_EIP_RET, $r) ; discard edit
                    ContinueLoop
                EndIf
            Next
            ; copy remaining edits
            $aLV_Edits = $aLV_EIP_RET
        EndIf

... also fancied a combo box that auto-drops when editing, so I added this to __GUIListViewEx_EditProcess :

....
        ; Set focus to editing control
        _WinAPI_SetFocus($hTemp_Edit)
        ; Check "select all" flag state
        If Not $aGLVEx_Data[$iLV_Index][11] Then
            GUICtrlSendMsg($cGLVEx_EditID, 0xB1, 0, -1) ; $EM_SETSEL
        EndIf

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Edit by DMOB <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If $iEditType = 2 Then
            _SendMessage($hCombo, 0x14F, True) ; $$CB_SHOWDROPDOWN = 0x14F
        EndIf
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Edit by DMOB <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        ; Copy array for manipulation
        ......

I must say I love your UDF and the way you wrote it, allows a lot of tweaking and tinkering :dance:

Edited by dmob

Share this post


Link to post
Share on other sites

#55 ·  Posted (edited)

dmob,

Glad you like the new additions.

I might steal that "drop-down on edit" idea, using the second parameter of _GUIListViewEx_SetEditStatus (currently True/False for readonly state when setting as a combo) along these lines:

0   - Standard combo
1   - Readonly combo
+2  - Dropdown on edit

That way the user can choose whether it happens. Let me have a play and see what I can do.

M23

Edit: Works a treat - reloaded the Beta code yet again. Thanks for that suggestion.

Edited by Melba23
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Melba23,

I use _GUICtrlListView_Create to create my listview and define the list view column headers using _GUICtrlListView_AddColumn.  I then use your _GUIListViewEx_ functions to do all the rest of the work with the listview.  This has now stumped me to understand how I programmatically change a column header text defined using _GUICtrlListView_Create

Do you know how I would go about doing this.

 

Many Thanks

 

Share this post


Link to post
Share on other sites

I`m with stupid. 

_GUICtrlListView_SetColumn( $hListView_Right, 6, "New Text")

is the answer.

 

Share this post


Link to post
Share on other sites

bourny,

You beat me to it!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#59 ·  Posted (edited)

Hi,

Final Beta release to check out recent additions:

  • Option to disable header resizing.
  • Custom editing a column using a user-defined function
  • Custom sorting a column using a user-defined function (now by individual column).
  • Option for an "auto dropdown" option when using combos to edit.

Here is an example script showing off the new functionalities:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Global $aRet

; Create GUI
$hGUI = GUICreate("GLVEx Beta Example", 500, 360)

; Create ListView
$cListView = GUICtrlCreateListView("Tom|Dick|Harry", 10, 10, 480, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView,$LVS_EX_FULLROWSELECT )
_GUICtrlListView_SetColumnWidth($cListView, 0, 150)
_GUICtrlListView_SetColumnWidth($cListView, 1, 150)
_GUICtrlListView_SetColumnWidth($cListView, 2, 150)

; Create array and fill Left listview
Global $aLV_List[15]
For $i = 0 To 14
    $aLV_List[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    GUICtrlCreateListViewItem("Tom " & $i & "|Dick " & $i & "|Harry " & $i, $cListView)
Next

; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text
$iLV_Index = _GUIListViewEx_Init($cListView, $aLV_List, 0, Default, Default, 1 + 8)

_GUIListViewEx_SetEditStatus($iLV_Index, "0;2", 9, _UserFunction)                       ; Column 0 & 2 editable using user function
_GUIListViewEx_SetEditStatus($iLV_Index, "1", 2, "Choice 1|Choice 2|Choice3", 1 + 2)    ; Col 1 uses a readonly combo which drops down automatically

; Set header data for edit - Col 0 uses an edit and cannot be resized
;                            Col 1 is not editable as column itself is not editable and can be resized
;                            Col 2 uses a combo and can be resized
Local $aHdrData[][] =  [["", "", ""], _                     ; Header colour not used so no need for titles
                        ["", "", ""], _                     ; or colours
                        ["", "", "New 1|New 2|New 3"], _    ; A delimited string forced a combo - empty means simple text
                        [1,  0,  0]]                        ; Column resizing mode set here
$iRet = _GUIListViewEx_LoadHdrData($iLV_Index, $aHdrData)

; Set sort options                                          ; Col 0 = normal sort (default if intialised)
_GUIListViewEx_UserSort($iLV_Index, "1")                    ; Col 1 = no sort (no function passed)
_GUIListViewEx_UserSort($iLV_Index, "2", _UserSortFunction) ; Col 2 = user sort function - in this case sorts on the numeric part

; This function initiates tooltips when items in col 0 are clicked as any path is likely to be too wide to fully display
_GUIListViewEx_ToolTipInit($iLV_Index, "0")

$cDisplay_Button = GUICtrlCreateButton("Show content", 10, 320, 230, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 260, 320, 230, 30)

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit

        Case $cDisplay_Button

            $aLV_List = _GUIListViewEx_ReturnArray($iLV_Index, 3)
            If Not @error Then
                _ArrayDisplay($aLV_List, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf

    EndSwitch

    ; This function must be in the idle loop to anable editing of any kind
    $vRet = _GUIListViewEx_EditOnClick("33")

    ; Save error value
    Local $iError = @error

    ; If column edited by user function then $vret reflect return values from that function
    ; If column editable in modes 1-3 (internal UDF editing) then an array of edited items returned
    ; If no edits occurred then function returns empty string - so check array exists before viewing
    If IsArray($vRet) Then
        ; Uncomment to see returned array if edited by UDF
        ;_ArrayDisplay($vRet, @error)
    ElseIf $vRet <> "" Then
        ; Uncomment to see returned values if edited with user function
        ;ConsoleWrite($vRet & " - " & $iError & " - " & @extended & @CRLF)
    EndIf

    ; This function enables the tooltips when cols 0 & 2 are clicked as the path is likely to be too wide to fully display
    _GUIListViewEx_ToolTipShow()

WEnd

; User function must take 4 parameters - no more, no less
; ListView handle, ListView UDF index, Row clicked, Column clicked
Func _UserFunction($hLV, $iIndex, $iRow, $iCol)

    ; Then depending on the column clicked - note that each column could have been set to a separate function if required
    Switch $iCol
        Case 0 ; Col 0 accepts an .au3 file
            $sRet = FileOpenDialog("Choose a file", "", "Files(*.au3)", 0, "", $hLV)
            If $sRet Then
                $aContent = _GUIListViewEx_ChangeItem($iIndex, $iRow, $iCol, $sRet)
            EndIf
        Case 2 ; Col 2 accepts a folder
            $sRet = FileSelectFolder("Choose a folder", "", 0, "", $hLV)
            If $sRet Then
                $aContent = _GUIListViewEx_ChangeItem($iIndex, $iRow, $iCol, $sRet)
            EndIf
    EndSwitch

    Return 1

EndFunc

; User sort function must take 5 parameters - no more no less - which match those used by _ArraySort
; ByRef array, Descending variable, Start (usually 1), End (usually 0, so need to convert to max index), Column to sort
Func _UserSortFunction(ByRef $aArray, $vDescending, $iStart, $iEnd, $iCol)

    If $iEnd = 0 Then $iEnd = UBound($aArray) - 1
    _ArrayColInsert($aArray, 0)
    For $i = $iStart To $iEnd
        $aArray[$i][0] = Number(StringRegExpReplace($aArray[$i][$iCol + 1], "^.\D+(\d+)$", "$1"))
    Next
    _ArraySort($aArray, $vDescending, $iStart, $iEnd, 0)
    _ArrayColDelete($aArray, 0)

EndFunc

And here is the UDF:

Comments welcome from all - new release should be later this week unless you lot find some problems.

M23

Edited by Melba23
Beta code removed
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

@melba,

Hi im confused with your example its for advance user Please can you give me an easy example for your

_GUIListViewEx_SaveListView

_GUIListViewEx_LoadListView

 

TIA...


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
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