Jump to content

GUIListViewEx - Deprecated Version


Melba23
 Share

Recommended Posts

My apologies Melba - you are absolutely correct.  This is an issue with standard listviews and not your UDF.  I should have checked this before bothering you.

I would regard this as a bug in the standard libraries (or perhaps Windows), as it causes difficulties for the programmer to accurately display listviews.  I don't want my columns expanding arbitrarily when data is inserted. 

Your function is amazing though and it fixes the issue for me just fine. (Although putting your code amongst my code is like putting something from the Louvre amongst a painting exhibition from primary school.)

In regards to the icons (subitems) I will have to forego the listview sorting functionality until you can find a way to handle them. I know you like a challenge!  :)

Good call with using _GUICtrlListView_SetExtendedListViewStyle - no more crashes now.

Thanks for your kind help.

Link to comment
Share on other sites

  • Moderators

Clark,

Hurrah! 2 solved out of 3 - not a bad day's work! :D

But I am afraid the icon problem looks a bit more complex - so 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

 

Link to comment
Share on other sites

  • Moderators

Clark,

I have been playing with the icon problem all day and I have got a solution of sorts - but it is horribly complex and would require a huge amount of work to make it compatible with the possibility of icons in any subitem and even more to get it into a usable format to integrate it into the UDF. So reluctantly I have decided that it is a step too far and I will not be adding this functionality to the UDF.

I have also been trying to combine the UDF with the _GUICtrlListView_RegisterSortCallBack function which does sort the icons as shown in the help file example - but there is obviously some conflict here as the two do not play at all nicely together. I will keep prodding at this solution - but I fear that once again getting everything into the UDF is likely to be more work that I am prepared to put in.

Sorry for such a negative reply - but as MeatLoaf used to sing 2 out 3 ain't bad. :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

 

Link to comment
Share on other sites

  • Moderators

dickjones,

I see my function headers went unread yet again: :(

; #FUNCTION# =========================================================================================================
; Name...........: _GUIListViewEx_ReturnArray
; Description ...: Returns an array reflecting the current content of an activated ListView
; Syntax.........: _GUIListViewEx_ReturnArray($iIndex[, $iCheck])
; Parameters ....: $iIndex - Index number of ListView as returned by _GUIListViewEx_Init
;                  $iCheck - If non-zero then the state of the checkboxes is returned (Default = 0) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
As for restoring the checkboxes, you will need to loop through the array returned by the function and check the required rows after loading the items. :)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • Moderators

dickjones007,

 

headers didnt went unread i just didnt understand some of them

Then you did the right thing in asking me to explain. :)

Let us run through the process in slow time.

 

Saving the data. Use the _GUIListViewEx_ReturnArray function to get the text currently in the various items of the ListView - and then run it again with the $iCheck parameter set to get a similar array for the checkbox states. You can then save these files - doing it directly with FileWriteFromArray might be a good choice or you could create your own custom file.

Loading the data. Read the saved files into arrays. I told you yesterday how to load the data returned by the _GUIListViewEx_ReturnArray function into the ListView - do that first. Then you will need to set the checkboxes so loop through the saved checkbox data array and check those that need it. Take a look in the Help file and see if you can find a function that might be useful - searching for "listview checked" might be a good way to start your search. ;)

Is that clear enough? :)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Sorry for such a negative reply - but as MeatLoaf used to sing 2 out 3 ain't bad. :D

 

 

Not a problem at all.   I imagine it is a lot more difficult for you to make a generic function that can handle the icons, that it would be for more me to create something specific to my use case.  I can probably store the icons in a 2d array or some such and then restore to their correct positions based on an index.   Unfortunately I will have to come back to this as I need to get the remainder of the program put to bed first - which will take me a few months.

edit: After some further testing, I wonder if your udf sorting is working the same as the native library sorting.  (This is not in relation to subitems btw, just regular listview fields.)  The reason I wonder is that when I load up the listbox (and your libraries listbox array) the first column displays it's contents in this numerical sequence:

10

102

103

117

124

189

213

72

This is after defining the listbox with $LVS_SORTASCENDING - obviously it uses ascii sorting sequence rather than true numerical sequence.

If I then press the column header to sort on that column, the order I get is:

10

72

102

103

117

124

189

213

So obviously whilst your library sorts it correctly, it does sort it differently than what the native library does. 

It is probably not that important but I thought it worth mentioning.

Edited by Clark
Link to comment
Share on other sites

  • Moderators

Clark,

The sort function used in the UDF is just _GUICtrlListView_SimpleSort, no more and no less - look at line #1315. But if you have set the $LVS_SORTASCENDING style for the ListView I would be very surprised if the sort worked as expected - no sooner do you re-sort the content than the sort style tries to re-re-sort it. I would stick with either the style or the header click - not both. :)

And we are talking of ListViews here, not ListBoxes - which are very different beasts. ;)

M23

Edit: And your suggested solution is exactly how I got the icon sorting to work. But it is a lot of work - are you sure you really need it? :huh:

Edited by Melba23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Hi Melba

Damn, in my head I think listview but my fingers type listbox.  :)

Yes, without the subitems staying with their correct rows I would have to forego sorting, which would be a shame.  But if there is a trigger I can track in the program code, similar to what is available for _GUIListViewEx_Editonclick, then I can easily put the subitems back in the right place after a sort.

Here is a screen from my app so you can see why:

14-01-20148-54-06AM_zpsef4a824e.png

I will remove the $LVS_SORTASCENDING as per your suggestion.

regards

Clark

Link to comment
Share on other sites

  • 1 month later...
  • Moderators

detefon,

That does not sound to difficult to arrange - probably in the form of a flag to prevent the content of a ListView from being dragged to another. I will try and produce something tomorrow. :)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • Moderators

Detefon,

Try this Beta version and see what you think - you can set a flag to disable the external drag/drop facility: :)

GUIListViewEx_Mod.au3

And here is a small example script to show it working: :)

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

#include "GUIListViewEx_Mod.au3"

$hGUI = GUICreate("Test", 400, 400)

; Create ListViews
$cLV_Tom = GUICtrlCreateListView("Tom",10, 30, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Tom, 0, 140)
$cLV_Dick = GUICtrlCreateListView("Dick",210, 30, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Dick, 0, 140)
$cLV_Harry = GUICtrlCreateListView("Harry",10, 230, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Harry, 0, 140)
$cLV_Fred = GUICtrlCreateListView("Fred",210, 230, 180, 160)
_GUICtrlListView_SetColumnWidth($cLV_Fred, 0, 140)

; Create arrays and fill ListViews
Global $aTom[5], $aDick[5], $aHarry[5], $aFred[5]
For $i = 0 To 4
    $aTom[$i] = "Tom " & $i
    GUICtrlCreateListViewItem($aTom[$i], $cLV_Tom)
    $aDick[$i] = "Dick " & $i
    GUICtrlCreateListViewItem($aDick[$i], $cLV_Dick)
    $aHarry[$i] = "Harry " & $i
    GUICtrlCreateListViewItem($aHarry[$i], $cLV_Harry)
    $aFred[$i] = "Fred " & $i
    GUICtrlCreateListViewItem($aFred[$i], $cLV_Fred)
Next

; Initiate ListViews and set differing external drag/drop states
GUICtrlCreateLabel("No external drag/drop", 10, 10, 180, 20)
$iLV_Tom = _GUIListViewEx_Init($cLV_Tom, $aTom, 0, 0, True, 64) ; Set flag
GUICtrlCreateLabel("External drag/drop", 210, 10, 180, 20)
$iLV_Dick = _GUIListViewEx_Init($cLV_Dick, $aDick)
GUICtrlCreateLabel("No external drag/drop", 10, 210, 180, 20)
$iLV_Harry = _GUIListViewEx_Init($cLV_Harry, $aHarry, 0, 0, True, 64) ; Set flag
GUICtrlCreateLabel("External drag/drop", 210, 210, 180, 20)
$iLV_Fred = _GUIListViewEx_Init($cLV_Fred, $aFred)

GUISetState()

_GUIListViewEx_MsgRegister()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

It would not be difficult to separate out the "drag" and "drop" behaviour so that ListViews could be either "givers" or "takers", as well as "both" and "neither" as in this example - would that be of interest? :huh:

M23

Edited by Melba23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Melba, thank you!

I understand your explanation and agree, sometimes it's necessary a undragable listview.

About your mod code, yes, the listview is undragable, nothing is moved for it.

But, if you (for me, at least), when drag any items from dragable listview for anywhere, like columns header, and I create a combobox too, and drag one or all listview's iten for another controls, sometimes everything is gone!

The code is very hard/complex for me at this moment, but, I think... maybe I am wrong... is only a suspect... when you drag any iten's listview, the code does not filter the destiny, sometimes allow drag a iten's listview to a non-listview, like a button, headers column or another control, and the final function for this operation, is delete all itens from the source listview.

I greatly appreciate your work and I have great interest in the maturation of this code.

Best regards, Detefon.

Edited by Detefon

Visit my repository

Link to comment
Share on other sites

  • Moderators

Detefon,

 

the code does not filter the destiny, sometimes allow drag a iten's listview to a non-listview

The UDF does indeed filter the drag/drop destination inside the _GUIListViewEx_WM_MOUSEMOVE_Handler function. But if you can provide a small reproducer script and a list of actions to take to make all the items vanish I would be happy to investigate further. :)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

  • 4 weeks later...

I just updated _GuiListViewEx from an earlier version (GUIListViewEx_Mod dated 4/18/13) hoping it would fix a different problem relating to some changes in my code but it created new problems unrelated to the new code.

Here is part of my code (the whole file is over 2000 lines and depends on ancillary files and reg entries):

GUISetState(@SW_SHOW)

; Initiate LVEx - no count parameter - default insert mark colour (black) - 2 enables editing
$iLVIndex = _GUIListViewEx_Init($hdatalist, $listarray, 0, 0xFF0000, False, 2, "1-15"); column zero is not editable
_GUIListViewEx_MsgRegister(True, False, False) ; enable notify but not dragging

;_ArrayDisplay($listarray)
While 1 ; wait for button clicks or window adjustment
    $addmode = 0
    $importline = 0
    Sleep(100) ; keep the GUI from eating up all the CPU cycles
    ;look for edits
    If Not $setupmode Then
        GUICtrlSetOnEvent($addbutton, "") ; disable $addbutton while editing so the closing enter saving the edits doesn't invoke $addbutton
        $editlist = _GUIListViewEx_Editonclick(-33)
        GUICtrlSetOnEvent($addbutton, "AddLine") ; reenable $addbutton
        If @error Then
            ConsoleWrite("Line 313: " & @error & " at " & @MIN & @SEC & @CRLF)
        Else
            ;_ArrayDisplay($editlist, @error)
            If IsArray($editlist) Then
                If $editlist[0][0] Then
                    $listarray = _GUIListViewEx_ReadToArray($hdatalist) ; read modified listview to array
                    SaveData()
                EndIf
            EndIf
        EndIf
    EndIf
Wend

As far as I can tell, the only change that had to be made was to swap the position of $fImage and $iAdded in _GUIListViewEx_Init, which I did.  What's happening is that most of the time now when I doubleclick on a line to edit, nothing happens, i.e. it never sees the doubleclick.  Sometimes, though, it does work, except that the edit entry appears 5 lines above where I clicked.  Once it does appear, it works normally and I can arrow back and forth as expected (again, displaying 5 lines high).

Elsewhere in the code, I have:
$temparray = _GUIListViewEx_Insert($newdata) ; add the new line
    ;_ArrayDisplay($temparray)
    GUICtrlSetOnEvent($addbutton, "") ; disable $addbutton while editing so the closing enter saving the edits doesn't invoke $addbutton
    GUICtrlSetState($addbutton, $GUI_HIDE)
    ConsoleWrite("ready to edit" & @CRLF)
    $editlist = _GUIListViewEx_EditItem($iLVIndex, $lnum, 1, 33) ; edit the new line, starting with column 1
    If @error Then ConsoleWrite("line 564 error " & @error & @CRLF)
    GUICtrlSetState($addbutton, $GUI_SHOW)
    GUICtrlSetOnEvent($addbutton, "AddLine") ; reenable $addbutton

The new line gets added OK and it goes into edit mode, but again the editing inputs are out of place... in this case, 6 lines above where they should be.

None of this happened before updating the UDF.

The original problem I was trying to solve is something different.  I'm working on some code changes involving the addition of a new function that (while the original GUI and listview are open) adds a new GUI and new listview (that doesn't use GUIListViewEx).  The use makes some changes, the new GUI is deleted, and data from the new listview is added to the original listview using the same second bit of code above.  In this case (with the old version of the UDF), _GUIListViewEx_EditItem doesn't work... the line highlights but doesn't show an edit field.  If I try to arrow across, the existing text in any subitem starting with a numeric character is wiped out and replaced with a zero.  With the new version of the UDF, it seems to simply blow past the edit mode.
 
Link to comment
Share on other sites

  • Moderators

Dana,

Sorry to hear about all that - but this is by far the most complex UDF I have ever tried to write and ListViews are generally regarded to be the most difficult and buggy controls around so debugging is not easy even with a reproducer script. Looking at those couple of code snippets I am afraid I have absolutely no idea where I should even start looking for the problem. If you could provide a working script showing the errant behaviour (or even let me see the whole of your current code) I would be happy to take a look. :)

M23

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

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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