Jump to content

Recommended Posts

  • Moderators
Posted (edited)

Dana,

Sorry it has taken so long to reply - I was away visiting the in-laws (I survived!).

Your points in reverse order:

Post #80: I had already noticed the problem with out-of-view items and was working on it while I was away. This new Beta does exactly what you requested.

Post #78: I cannot reproduce the error when editing the last line - whether the ListView is full or empty. If it still occurs with the new Beta then can you let me have the script you use.

Post #77: I am afraid that I do not understand what you are trying to explain. The "shadow" array containing the current content is updated after each confirmed edit - which my tests confirm. Can you explain more clearly what it is you expect to happen and perhaps post a runnable reproducer?

Post #76: The new Beta allows you to set the behaviour for each axis separately.

So here is the new Beta and an example to show it working:

<Code removed - see new Beta below>

You may need to read the changelog as well - there are quite a few changes from the last Beta:

Warning: Script-breaking changes to previous Beta versions of the UDF!!! :o

New:

- The _GUIListViewEx_EditItem function allows for programatic selection of an item to be edited. The item does not have to be in one of the columns editable on double-clicking.

- When using the _GUIListViewEx_EditItem function or after a double-click on an editable item, the user can choose to limit the edit to that single item/subitem (default) or for the {TAB} and cursor arrow keys to move the edit location around the ListView, scrolling the items into view if necessary. In the latter case, when the edit location reaches the edge of the ListView the user can choose to terminate the edit process, to remain at that point, or loop to the opposite edge of the ListView. The action to take can be set independently for each axis of movement.

- The GUIListViewEx_ReadToArray function reads the current content of a ListView into an array which can then be used as a parameter in the GUIListViewEx_Init function.

Changed:

- The function placed in the idle loop to action the edit process on a double-click has been renamed to _GUIListViewEx_Edit&#111;nclick and has lost the parameter to set the editable columns - but gained a parameter which determines the edit process behaviour (see the explanation above).

- The function to register various Windows messages has been renamed to _GUIListViewEx_MsgRegister as its previous name (_DragRegister) suggested it was only required to activate item dragging. In fact the WM_NOTIFY message needs to be registered for sorting and editing as well as dragging - the other other messages need only be registered if dragging is required.

- The _GUIListViewEx_ReturnArray function has lost an underscore from its name to match the format of the other function names.

- The _GUIListViewEx_Init function now takes an additional parameter to define the columns which are editable - the default setting is "*" (all columns). The columns can be entered singly or as ranges e.g. "1;2;5-6;8-9". All ListView rows are permanently editable.

- Several new "Internal Use Only" functions have been added and many minor code changes have been made throughout the UDF.

Let me know what you think. :)

Clark,

Delighted that you find the UDF useful - any comments from you on the new version would also be welcome. :)

M23

Edit:

I might have found the problem with the crash when editing the last line - it happened to me when I created a ListView filled with empty elements and did not match the $iStart parameters in _GUIListViewEx_ReadToArray and _GUIListViewEx_Init. As a result I had one too few elements in the shadow array and got the error when editing the last line. This could well be your problem.

I did not take my own advice - the function header does state: :>

; Remarks .......: If the returned array is used in GUIListViewEx_Init the $iStart parameters must match in the 2 functions
Edited by Melba23
Removed code

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

 

Posted

Post 80 (out of view items)-- beautiful.

Post 78 (last line editing) -- I got it now. Problem was I incorrectly had 1, not 0, for the $iStart parameter in _GUIListViewEx_Init. FIxing that took care of the last line edit problem. The other aspect of the problem was editing a new line added at the end of the list; I solved that by using _GUIListViewEx_Close and then _GUIListViewEx_Init again after adding the new line, before using _GUIListViewEx_EditItem.

Post 77 - what I mean is that I use $listarray to fill the listview, then pass $listarray to _GUIListViewEx_Init:

$iLVIndex = _GUIListViewEx_Init($hdatalist, $listarray, 1, 0xFF0000, 2, False, "1-15")

After a successful edit, the contents of $listarray are unchanged, but I can get the changes to the listview by using _GUICtrlListView_GetItemText.

Post 76-- again, beautiful!

  • Moderators
Posted

Dana,

I was just editing the post above to suggest that the post #78 problem might be just that - happy to see I was correct! If you use the UDF to add lines to the ListView, it adds lines to the shadow array automatically - it might be worth doing that rather then the _Close/_Init manoeuvre. ;)

I am delighted that you like the changes to the out-of-view item and separate axis behaviour - I spent a long time thinking about how to implement them while getting bored at the in-laws. :D

I understand the array comment now - you are under a misapprehension about how the UDF stores changes to the ListView. The array you use in the _Init function can be deleted once you have used it as a parameter - the UDF keeps a copy of it internally as a "shadow" array and it is this which is modified as the UDF runs. You can recover this internal array at any time by using the _GUIListViewEx_ReturnArray function - and certain functions return it as they exit. Is that clearer? :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

 

  • Moderators
Posted

Dana,

There was one more request in post #76 that I forgot to mention - clicking elsewhere in the ListView to move the edit. I am afraid I cannot manage to get this to happen with a simple double-click - you actually need a triple-click. The first click exits the current editing function and then a double click re-enters it in the new location (assuming it is a valid column). Sorry about that - it got too difficult to do it directly. :(

By the way, did you notice the new way to enter the valid columns? I think "1-15" is a little more elegant than "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15". :D

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

 

Posted

Thanks,

I guess I still don't quite understand about the shadow array... I was under the impression that if you passed the array name to _init, it would use that as the shadow array rather than creating a new one. Since that's an optional parameter and _init can create the shadow array from the listview itself, what's the advantage of giving it the original array name?

In my case, rather than deleting the original array, I'm refreshing it as needed using _ReadToArray now, rather than using _GUICtrlListView_GetItemText.

Re clicking elsewhere, I was hoping for a single click to move the edit within that same group of edits, like most other programs do... it's what one tends to automatically do if, say, you want to edit columns 2 and 12 with no changes in between. Right now, single clicking anywhere cancels the current edit.

And yes, the simplified way to enter columns is definitely more elegant. :)

Posted

Here's another issue: Let's say that _Editonclick or _EditItem was invoked with an $iEditMode allowing multiple edits. You change one or two fields but then cancel using ESC or other click. Can you ad an @error to indicate this? This way, you could save the edits that were completed, or throw them all away, as desired. Perhaps an input parameter could also be added to cause _Editonclick or _EditItem to keep what edits were completed, or revert back to the original if editing is canceled.

  • Moderators
Posted (edited)

Dana,

The shadow array works like that because that is how I coded the UDF - and I wrote a specific function and set return values from others so that updating the original array would be as easy as: ;)

$listarray = _GUIListViewEx_ReturnArray($iLVIndex)

; or

$listarray = _GUIListViewEx_Insert($vData)
$listarray = _GUIListViewEx_Delete
$listarray = _GUIListViewEx_Up
$listarray = _GUIListViewEx_Down

Accordingly, I am not of a mind to recode the entire UDF to amend the original array ByRef. ;)

Single-clicks on ListViews are very often eaten by the control itself as it interprets them as a selection - this is why I went for the double-click as the edit trigger initially. As to the "like most other programs do" comment, you need to remember that we are dealing with a ListView control here, not a specifically designed spreadsheet which can be coded to deal with clicks as it wishes. MS have made the ListView as it is and we are constrained in our ability to interact with ListViews by the limitations native to this class of control. :)

I will have a think about how I might implement your wish for a "Cancel all edits on ESC / Confirm all edits on ENTER" ability - but do not hold your breath. ;)

Any other requests? :P

M23

Edited by Melba23
Typos

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

 

Posted

If a single click somewhere in the list can't be implemented to move the edit selection, can it be ignored so that it won't cause an exit from editing?

  • Moderators
Posted

Dana,

can it be ignored so that it won't cause an exit from editing?

Of course, as that was what happened until you asked for the ability to move the edit position within the ListView by clicking! :D

And I think I have the "Abandon all on ESC" option working - if the $iEditMode parameter is set to a negative value then pressing ESC would reset all the previously confimed edits. I need to test some more, but that will be for tomorrow - it has been a long day. :)

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

 

  • Moderators
Posted (edited)

Dana,

Here is the latest Beta incorporating the "Abandon all on ESC" option and removing the "click on other item to edit" functionality (of course clicking outside the ListView being edited still cancels the edit process) - there is also a modified example which allows the user to select the required ESC mode:

<code removed>

I have removed all previous Betas from the thread. Please let me know if you have any other requests for me to incorporate before I issue a release version of the UDF. I will continue testing during the day but this Beta seems pretty stable to me at present. ;)

And of course I welcome comments from anyone else reading this as well. :)

M23

Edited by Melba23
Beta code removed

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

 

Posted

Looks good. I thought there was an issue but it was on my end... I wasn't handling the cleanup properly after inserting a line and then canceling it... I originally had 15 entry boxes to add a line to the listview which I then destroyed after reading them but using your UDF to add a line and edit in place is a lot cleaner.

Just curious... what is the [0][1] value in the _Editonclick or _EditItem returned array?

  • Moderators
Posted

Dana,

I use that element of the array as a flag for the type of event that ended the edit process - it is the Hex code of the key/mouse button pressed (look at _IsPressed to check the values) or 0x00 if the focus is lost. Storing the key code like that makes it easy to wait until the key is released before continuing, checking whether it is a confirmation/abandon event, and what to do if the edit is to move. Initially I though it might have some utility to the user - but as I have yet to discover just what that might be I will perhaps use a Local variable in its place! :)

I have added the "triple-click on ListView to move the edit" as an option - I quite liked it even though you did not, so now we are both happy. ;)

I will do some more testing this evening and release a new version tomorrow. Thanks for the prods to get the UDF working as you wanted - it was fun recoding it. :)

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

 

  • Moderators
Posted

[NEW VERSION] - 19 Apr 13

Warning: Major script-breaking changes to previous release versions of the UDF!!! :o

New and changes in this release:

New:

- The _GUIListViewEx_EditItem function allows for programatic selection of an item to be edited. The item does not have to be in one of the columns editable on double-clicking (see below).

- When using the _GUIListViewEx_EditItem function or after a double-click on an editable item, the user can choose to limit the edit to that single item/subitem (default) or for the {TAB} and cursor arrow keys to move the edit location around the ListView, scrolling the items into view if necessary. In the latter case, the user can choose:

- The action to take when the edit location reaches the edge of the ListView - terminate the edit process, remain at that point, or loop to the opposite edge of the ListView. The action to take can be set independently for each axis of movement.

- The action taken when {ESC} is pressed - either abandon just the current edit leaving previous edits in place or reset all edits made in the current editing session.

- The GUIListViewEx_ReadToArray function reads the current content of a ListView into an array which can then be used as a parameter in the GUIListViewEx_Init function.

Changed:

The _GUIListViewEx_Init function has several changes:

The function now takes an additional parameter to define the columns which are editable - the default setting is "all columns". The zero-based column numbers can be entered singly or as ranges e.g. "0;2;4-6;8-10;12". All ListView rows are permanently editable.

- The order of the $fImage and $iAdded parameters in the _GUIListViewEx_Init function has changed to keep the various parameters arranged in logical groups (dragging - sorting & editing).

- The $iAdded parameter has an additional option - if the ListView is editable then this option enables you to move the edit control within the same ListView by triple-clicking (a single-click to close the current edit and then a double-click to relocate it). It is always possible to swap the edit process to another ListView by double-clicking within it.

- The function to register various Windows messages has been renamed to _GUIListViewEx_MsgRegister as its previous name (_DragRegister) suggested it was only required to activate item dragging. In fact the WM_NOTIFY message needs to be registered for sorting and editing as well as dragging - the other other messages need only be registered if dragging is required.

- The function placed in the idle loop to action the edit process on a double-click has been renamed to _GUIListViewEx_Edit&#111;nclick and has lost the parameter to set the editable columns - but gained a parameter which determines the edit process and {ESC} key behaviour (see the explanation above).

- The _GUIListViewEx_ReturnArray function has lost an underscore from its name to match the format of the other function names.

- Several new "Internal Use Only" functions have been added and many minor code changes have been made throughout the UDF.

Sorry about the scriptbreaking changes - I hope you feel that the added functionality to the UDF is worth the trouble of changing your scripts. Thanks to Dana for the prods to get me to do most of what he wanted. :thumbsup:

New UDF and examples in the first post. :)

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

 

Posted

Dear Melba23,

Great udf, I like it very much. Thank you for sharing.

I have been playing around with your examples, more specifically with example 1.

To allow resizing of the GUI, I added GUICtrlSetResizing on every Ctrl, but I bumped into an issue with _GUICtrlListView_Create. It looks like there is no way to dock the ListView control in the GUI, unless I have missed something.

When I replace _GUICtrlListView_Create with GUICtrlCreateListView, the issue seems to be solved, but then the udf ListView functions collapse.

In the attached modified Example_1, between line 48 and 54, you can test it yourself.

Any idea what the cause is of the issue? Is it solvable? (I couldn’t find a way)

(sorry, it looks like the indentation is lost when I paste the code...)

#include
#include

#include "GUIListViewEx.au3"

#include ; Just for display in example

Opt("GUICloseOnESC", 0)

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 1", 640, 490, Default, Default, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Multiple selection - no count - sort && editable (0 && 2)", 10, 5, 300, 35)
GUICtrlSetResizing ( -1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP))
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKTOP) ) ; lock the ListView to the edges


_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
; Set font
GUICtrlSetFont($cListView_Left, 12, Default, Default, "Courier New") ; Note edit control will use same font

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
For $i = 0 To UBound($aLV_List_Left) - 1
If Mod($i, 5) Then
$aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
Else
$aLV_List_Left[$i] = "Tom " & $i & "||Harry " & $i
EndIf
GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next
;
; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable (0 & 2) - only cols 0 & 2 editable
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2, "0;2")

; Create Right ListView
;~ GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 300, 35)
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 200, 35)
GUICtrlSetResizing ( -1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP))
#========================================
;~ ; cannot dock this Ctrl in the GUI
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKTOP) ) ; lock the ListView to the edges

;~ ; this is dockable
;~ $hListView_Right = GUICtrlCreateListView("", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
;~ GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKTOP) ) ; lock the ListView to the edges
#========================================
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)

; Fill Right ListView
For $i = 1 To $iCount_Right
_GUICtrlListView_AddItem($hListView_Right, "Peter " & $i -1)
If Mod($i, 4) Then
_GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i -1, 1)
EndIf
_GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i -1, 2)
Next

; Read array from Right ListView
Global $aLV_List_Right = _GUIListViewEx_ReadToArray($hListView_Right, 1)
; The array as read from Right ListView and used subsequently
;_ArrayDisplay($aLV_List_Right, "Read from Right ListView")

; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - editable - all cols editable by default
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlCreateLabel(": Single Edit" & @CRLF & ": Exit Edge" & @CRLF & ": Stay Edge" & @CRLF & ": Loop Edge", 340, 70, 65, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE) )
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKLEFT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKLEFT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKHCENTER,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKHCENTER,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cEdit_Left_Button = GUICtrlCreateButton("Edit Left 1,1", 10, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKLEFT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cEdit_Right_Button = GUICtrlCreateButton("Edit Right 5,0", 220, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKHCENTER,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKRIGHT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKRIGHT,$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 70)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM,$GUI_DOCKRIGHT +$GUI_DOCKWIDTH,$GUI_DOCKHEIGHT) )

GUISetState()

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

; Set the left ListView as active
_GUIListViewEx_SetActive(1)

Switch _GUIListViewEx_GetActive()
Case 0
$sMsg = "No ListView is active"
Case 1
$sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
Case 2
$sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
; MsgBox(0, "Active ListView", $sMsg)

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $cExit_Button
Exit
Case $cInsert_Button
; Prepare data for insertion
Switch $aGLVEx_Data[0][1]
Case 1
; String format with multi-column native ListView
$vData = "Tom " & $iCount_Left & "|Dick " & $iCount_Left & "|Harry " & $iCount_Left
$iCount_Left += 1
_GUIListViewEx_Insert($vData)
Case 2
; Array format with multi-column UDF ListView
Global $vData[3] = ["Peter " & $iCount_Right, "Paul " & $iCount_Right, "Mary " & $iCount_Right]
$iCount_Right += 1
_GUIListViewEx_Insert($vData)
EndSwitch

Case $cDelete_Button
_GUIListViewEx_Delete()

Case $cUp_Button
_GUIListViewEx_Up()

Case $cDown_Button
_GUIListViewEx_Down()

Case $cDisplay_Left_Button
$aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
If Not @error Then
_ArrayDisplay($aLV_List_Left, "Returned Left")
Else
MsgBox(0, "Left", "Empty Array")
EndIf
$aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index, 1)
If Not @error Then
_ArrayDisplay($aLV_List_Left, "Returned Left Checkboxes")
Else
MsgBox(0, "Left", "Empty Check Array")
EndIf

Case $cDisplay_Right_Button
$aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
If Not @error Then
_ArrayDisplay($aLV_List_Right, "Returned Right")
Else
MsgBox(0, "Right", "Empty Array")
EndIf

Case $cEdit_Left_Button
; Note abilty to edit columns which cannot be edited via doubleclick
$aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
_ArrayDisplay($aRet, @error)

Case $cEdit_Right_Button
$aRet = _GUIListViewEx_EditItem($iLV_Right_Index, 5, 0, $iEditMode) ; Use combos to change EditMode
_ArrayDisplay($aRet, @error)

Case $cCombo_Row
Switch GUICtrlRead($cCombo_Row)
Case 0
; Both must be set to 0
GUICtrlSetData($cCombo_Col, 0)
Case Else
; Neiterh must be set to 0 - so match selections
If GUICtrlRead($cCombo_Col) = 0 Then
GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
EndIf
EndSwitch
; Set required edit mode
$iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

Case $cCombo_Col
Switch GUICtrlRead($cCombo_Col)
Case 0
GUICtrlSetData($cCombo_Row, 0)
Case Else
If GUICtrlRead($cCombo_Row) = 0 Then
GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
EndIf
EndSwitch
$iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

Case $cCombo_Reset
; Toggle edit mode value to switch ESC modes
$iEditMode *= -1

EndSwitch

; No longer any need to define columns as now done in _Init function
$aRet = _GUIListViewEx_Editonclick($iEditMode) ; Use combos to change EditMode
; _ArrayDisplay($aRet, @error) ; Uncomment to see returned array

WEnd

I also found an anomaly with ‘insert’ on the (RH) UDF Listview.

When you insert a row for the first time, _GUIListViewEx_Insert function will always insert the array at 0+1, and that is wrong.

The guilty is $aGLVEx_Array[0][0] as always 0 the first time.

If you comment out line 478 (and probably 463 for 1D arrays) the row inserted is at the correct position.

;~       If $aGLVEx_Array[0][0] = 0 Then $iInsert_Index = 0

I didn’t search why you have set these two lines of code, but you may have to revise your logic on this. Up to you to verify :)

Grtz, GreenCan

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

  • Moderators
Posted (edited)

GreenCan,

Thanks for the testing and comments.

Resizing: GUICtrlSetResizing only works on controls created with the native functions - if you use UDF created controls you have to look after the resizing and relocation yourself inside a message handler. I will try and produce an example later today. But I do not understand your comment about the UDF "collapsing" if you replace the UDF ListView with a native one - you have to adjust all the code related to its creation and filling, but then it works just fine:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

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

Opt("GUICloseOnESC", 0)

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 1", 640, 490, Default, Default, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Multiple selection - no count - sort && editable (0 && 2)", 10, 5, 300, 35)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP))
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_EX_FULLROWSELECT)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKTOP)) ; lock the ListView to the edges

_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
; Set font
GUICtrlSetFont($cListView_Left, 12, Default, Default, "Courier New") ; Note edit control will use same font

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
For $i = 0 To UBound($aLV_List_Left) - 1
    If Mod($i, 5) Then
        $aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    Else
        $aLV_List_Left[$i] = "Tom " & $i & "||Harry " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next
;
; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable (0 & 2) - only cols 0 & 2 editable
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2, "0;2")

; Create Right ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 200, 35)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP))

#========================================
$cListView_Right = GUICtrlCreateListView("", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKTOP) ) ; lock the ListView to the edges
_GUICtrlListView_SetExtendedListViewStyle($cListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($cListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($cListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($cListView_Right, "Mary", 83)

; Fill Right ListView
For $i = 0 To $iCount_Right - 1
    If Mod($i, 4) Then
        $aLV_List_Right = "Peter " & $i & "|Paul " & $i & "|Mary " & $i
    Else
        $aLV_List_Right = "Peter " & $i & "||Mary " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List_Right, $cListView_Right)
Next
#========================================

; Read array from Right ListView
Global $aLV_List_Right = _GUIListViewEx_ReadToArray($cListView_Right, 1)
; The array as read from Right ListView and used subsequently
;_ArrayDisplay($aLV_List_Right, "Read from Right ListView")

; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - editable - all cols editable by default
$iLV_Right_Index = _GUIListViewEx_Init($cListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel(": Single Edit" & @CRLF & ": Exit Edge" & @CRLF & ": Stay Edge" & @CRLF & ": Loop Edge", 340, 70, 65, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cEdit_Left_Button = GUICtrlCreateButton("Edit Left 1,1", 10, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cEdit_Right_Button = GUICtrlCreateButton("Edit Right 5,0", 220, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 70)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT + $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))

GUISetState()

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

; Set the left ListView as active
_GUIListViewEx_SetActive(1)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
; MsgBox(0, "Active ListView", $sMsg)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_Button
            ; Prepare data for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; String format with multi-column native ListView
                    $vData = "Tom " & $iCount_Left & "|Dick " & $iCount_Left & "|Harry " & $iCount_Left
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with multi-column UDF ListView
                    Global $vData[3] = ["Peter " & $iCount_Right, "Paul " & $iCount_Right, "Mary " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index, 1)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left Checkboxes")
            Else
                MsgBox(0, "Left", "Empty Check Array")
            EndIf

        Case $cDisplay_Right_Button
            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cEdit_Left_Button
            ; Note abilty to edit columns which cannot be edited via doubleclick
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            _ArrayDisplay($aRet, @error)

        Case $cEdit_Right_Button
            $aRet = _GUIListViewEx_EditItem($iLV_Right_Index, 5, 0, $iEditMode) ; Use combos to change EditMode
            _ArrayDisplay($aRet, @error)

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    ; Both must be set to 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    ; Neiterh must be set to 0 - so match selections
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            ; Set required edit mode
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    ; No longer any need to define columns as now done in _Init function
    $aRet = _GUIListViewEx_Edit&#111;nclick($iEditMode) ; Use combos to change EditMode
    ; _ArrayDisplay($aRet, @error) ; Uncomment to see returned array

WEnd

I hoep it works fine for for you too. :)

Insertion: Ooops - I can see the problem. :> The error occurs in the new _GUIListViewEx_ReadToArray function where I was not setting the correct value into the returned [0][0] element of the returned array. Please try this revised version and let me know if it cures the problem for you - it does for me:

<Beta code removed - see first post for latest release version>

If you can confirm that it works, I will release a BUGFIX version later to day. :)

M23

Edit:

Here is an example of how you can resize a UDF-created ListView yourself using a Message handler: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

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

Opt("GUICloseOnESC", 0)

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 1", 640, 490, Default, Default, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Multiple selection - no count - sort && editable (0 && 2)", 10, 5, 300, 35)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP))
$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKTOP)) ; lock the ListView to the edges

_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
; Set font
GUICtrlSetFont($cListView_Left, 12, Default, Default, "Courier New") ; Note edit control will use same font

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
For $i = 0 To UBound($aLV_List_Left) - 1
    If Mod($i, 5) Then
        $aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    Else
        $aLV_List_Left[$i] = "Tom " & $i & "||Harry " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next
;
; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable (0 & 2) - only cols 0 & 2 editable
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2, "0;2")

; Create Right ListView
;~ GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 300, 35)
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 200, 35)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKTOP))
#========================================
;~ ; cannot dock this Ctrl in the GUI
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKTOP)) ; lock the ListView to the edges

;~ ; this is dockable
;~ $hListView_Right = GUICtrlCreateListView("", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
;~ GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKTOP) ) ; lock the ListView to the edges
#========================================
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)

; Fill Right ListView
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next

; Read array from Right ListView
Global $aLV_List_Right = _GUIListViewEx_ReadToArray($hListView_Right, 1)
; The array as read from Right ListView and used subsequently
;_ArrayDisplay($aLV_List_Right, "Read from Right ListView")

; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - editable - all cols editable by default
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel(": Single Edit" & @CRLF & ": Exit Edge" & @CRLF & ": Stay Edge" & @CRLF & ": Loop Edge", 340, 70, 65, 80)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetResizing(-1, BitOR($GUI_DOCKVCENTER, $GUI_DOCKHCENTER, $GUI_DOCKSIZE))
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cEdit_Left_Button = GUICtrlCreateButton("Edit Left 1,1", 10, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cEdit_Right_Button = GUICtrlCreateButton("Edit Right 5,0", 220, 430, 200, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKHCENTER, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 70)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT + $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT))

GUISetState()

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

; Set the left ListView as active
_GUIListViewEx_SetActive(1)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
; MsgBox(0, "Active ListView", $sMsg)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_Button
            ; Prepare data for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; String format with multi-column native ListView
                    $vData = "Tom " & $iCount_Left & "|Dick " & $iCount_Left & "|Harry " & $iCount_Left
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with multi-column UDF ListView
                    Global $vData[3] = ["Peter " & $iCount_Right, "Paul " & $iCount_Right, "Mary " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index, 1)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left Checkboxes")
            Else
                MsgBox(0, "Left", "Empty Check Array")
            EndIf

        Case $cDisplay_Right_Button
            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cEdit_Left_Button
            ; Note abilty to edit columns which cannot be edited via doubleclick
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            _ArrayDisplay($aRet, @error)

        Case $cEdit_Right_Button
            $aRet = _GUIListViewEx_EditItem($iLV_Right_Index, 5, 0, $iEditMode) ; Use combos to change EditMode
            _ArrayDisplay($aRet, @error)

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    ; Both must be set to 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    ; Neiterh must be set to 0 - so match selections
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            ; Set required edit mode
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    ; No longer any need to define columns as now done in _Init function
    $aRet = _GUIListViewEx_Edit&#111;nclick($iEditMode) ; Use combos to change EditMode
    ; _ArrayDisplay($aRet, @error) ; Uncomment to see returned array

WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; If it is our GUI
    If $hWnd = $hGUI Then
        ; Get the new size of the GUI
        Local $aSize = WinGetClientSize($hWnd)
        ; Determine new width and height of UDF ListView = original dimension * new GUI dimension / original GUI dimension
        Local $iLVWidth = 200 * $aSize[0] / 640
        Local $iLVHeight = 300 * $aSize[1] / 490
        ; Work out new X value for the ListView = current GUI width - border - ListView width
        Local $iLVX = $aSize[0] - 10 - $iLVWidth
        ; Move ListView
        WinMove($hListView_Right, "", $iLVX, 40, $iLVWidth, $iLVHeight)
    EndIf

EndFunc   ;==>_WM_SIZE

P.S. Once again the forum software is messing with one of the function names - it should read _GUIListViewEx_Edit+On+Click without the plus signs. :)

Edited by Melba23
Beta code removed

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

 

Posted

Thanks Melba23

You're fast ;)

First example:

Yes, I get it. I just didn't focus on changing the listview fill.

You may want to correct the example though because something went wrong at the end, and the example is not usable for other forum users at the moment...

; No longer any need to define columns as now done in _Init function

$aRet = _GUIListViewEx_Edit&#111;nclick($iEditMode) ; Use combos to change EditMode

; _ArrayDisplay($aRet, @error) ; Uncomment to see returned array

Revised GUIListViewEx

Yes, issue solved. But...

Same issue in the new udf line 862

Func _GUIListViewEx_Edit&#111;nclick($iEditMode = 0, $iDelta_X = 0, $iDelta_Y = 0)

Example with Message Handler

Yes, that works perfectly. It looks like you had the answer ready and were waiting for the question :)

I am wondering which of the both examples (having obviously the same result) is program-wise the most efficient code. I suppose that GUICtrlCreateListView will also use a message handler to manage the Docking, right?

GreenCan

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

  • Moderators
Posted

GreenCan,

That is the forum software corrupting the text - I already mention it in the first post:

P.S. Once again the forum software is messing with one of the function names - it should read _GUIListViewEx_Edit+On+Click without the plus signs

That is why I am removing the Beta codes from the thread as I go and only putting a zip file into the first post. ;)

As you confirm my fix to the problem you found, I will release a BUGFIX version tomorrow. :)

I am glad you like the $WM_SIZE example - as you can see it is not difficult to do if you use it correctly. As to which is the best - it depends on what you want to do with your ListView. In general, I tend to use the native controls if I can and only use the UDF controls if I need some of the really advanced features that they offer. :)

mesale0077,

Thanks for the compliments - and the suggestion. I will look into it how I might implement it - but as I often say, do not hold your breath. ;)

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

 

Posted (edited)

Hi Melba

Thanks for all the work on this. I was very happy with the first version, which I got working with no difficulty whatsoever. The lastest version (as of this post), well, I'm probably doing something dumb but I can't get it to work. :(

I am getting this error on line 1689 of your udf:

$aSplit[$aLocation[1] + 1] = $sItemNewText

This is after I enter a field, edit it, then hit either edit or tab.

I have included my code (a cut down version of the code with only the relevant bits) so you can determine whether it is my mistake (most likely) or something in your udf.

#include
#include
#include
#include
#include "GUIListViewEx.au3"
#include
#include
#include
#include

Global $lvitem[50],$iLV_List,$listbox,$hImage,$iEditMode = 0

#Region ### START Koda GUI section ### Form=K:\AutoIT\Kerberos\Working\Kerberos Plan a Release.kxf
$Form1 = GUICreate("Kerberos - Plan a Release", 947, 662, -1, -1)
GUICtrlSetStyle($Form1, $LVS_ICON)
$lvMain = GUICtrlCreateListView("# |CRM ID |Name/Description |BU |Defect #|PO Number|Provider Ref |Provider | ",8, 200, 921, 396, BitOr($LVS_SORTASCENDING,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS),BitOR($LVS_EX_FULLROWSELECT,$WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_SetColumnWidth($lvMain, 0, 50)
_GUICtrlListView_SetColumnWidth($lvMain, 2, 320)
_GUICtrlListView_SetColumnWidth($lvMain, 8, 92)
$hListBox = GUICtrlGetHandle(-1)
$btnExit = GUICtrlCreateButton("Exit", 768, 608, 75, 25)
GUICtrlSetTip(-1, "Exit this screen without saving")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$lvitem[1]=GUICtrlCreateListViewItem("1|8000069709|Application Search Enhancement|Grants|2012|1234567890|FUJ999|Fujitsu" , $lvMain)
$lvitem[2]=GUICtrlCreateListViewItem("2|8000088092|New CRM Business Support Role|Grants|2099|5634567928|FUJ998|Fujitsu|", $lvMain)
$lvitem[3]=GUICtrlCreateListViewItem("3|8000073022|3 wage types for termination payments|Grants|" , $lvMain)
GUISetState(@SW_SHOW)


; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable (0 & 2) - only cols 4-7 editable
$iLV_List = _GUIListViewEx_Init($lvMain, $lvitem, 0, 0, False, 1 + 2, "4;5;6;7")
_GUIListViewEx_MsgRegister()
; Set the left ListView as active
_GUIListViewEx_SetActive(1)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnExit
Exit
EndSwitch
; No longer any need to define columns as now done in _Init function
$aRet = _GUIListViewEx_Editonclick($iEditMode) ; Allow keys to move edit location
;_ArrayDisplay($aRet, @error)
WEnd

edit: The forum software is removing my includes but they are really there. :)

Edited by Clark
  • Moderators
Posted (edited)

Clark,

All your own doing I am afraid! :D

You were not correctly creating the array to pass to the UDF. Your $lvitem array actually contained the ControlIDs of the ListView items and not the contents of the items - and the [0] element of the array had no content even though in the _Init function you set $iCount to 0 and so the UDF expected something. Hence the UDF tried to edit that empty element - and of course there was nothing in there to edit! :o

I suggest that you use the _GUIListViewEx_ReadToArray function to get a valid array once the ListView is filled - like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx_Mod.au3"

Global $lvitem, $iLV_List, $listbox, $hImage, $iEditMode = 0

$Form1 = GUICreate("Kerberos - Plan a Release", 947, 662, -1, -1)
GUICtrlSetStyle($Form1, $LVS_ICON)
$lvMain = GUICtrlCreateListView("# |CRM ID |Name/Description |BU |Defect #|PO Number|Provider Ref |Provider | ", 8, 200, 921, 396, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))

_GUICtrlListView_SetColumnWidth($lvMain, 0, 50)
_GUICtrlListView_SetColumnWidth($lvMain, 2, 320)
_GUICtrlListView_SetColumnWidth($lvMain, 8, 92)
$hListBox = GUICtrlGetHandle(-1)
$btnExit = GUICtrlCreateButton("Exit", 768, 608, 75, 25)
GUICtrlSetTip(-1, "Exit this screen without saving")
GUISetState(@SW_SHOW)

_GUIListViewEx_MsgRegister(True, False, False)

; Create the items without using an array <<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateListViewItem("1|8000069709|Application Search Enhancement|Grants|2012|1234567890|FUJ999|Fujitsu", $lvMain)
GUICtrlCreateListViewItem("2|8000088092|New CRM Business Support Role|Grants|2099|5634567928|FUJ998|Fujitsu|", $lvMain)
GUICtrlCreateListViewItem("3|8000073022|3 wage types for termination payments|Grants|", $lvMain)

; Now read the completed ListView into an array - note that the $iCount parameter matches that used in the _Init function below <<<<<<<<<<<<<<<
$lvitem = _GUIListViewEx_ReadToArray($lvMain, 0)

; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable (0 & 2) - only cols 4-7 editable
$iLV_List = _GUIListViewEx_Init($lvMain, $lvitem, 0, 0, False, 1 + 2, "4-7") ; I coded the elegant range syntax - so please use it!  <<<<<<<<<

; Set the left ListView as active
_GUIListViewEx_SetActive(1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnExit
            Exit
    EndSwitch
    ; No longer any need to define columns as now done in _Init function
    $aRet = _GUIListViewEx_Editonclick($iEditMode) ; Allow keys to move edit location
    ;_ArrayDisplay($aRet, @error)
WEnd

All clear? Please ask if not. :)

M23

P.S. Once again the forum software is messing with one of the function names - it should read _GUIListViewEx_Edit+On+Click without the plus signs. :)

Edited by Melba23
Poxy forum software

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

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...