Jump to content

_GUICtrlListViewSort ... paper dragon?


QA Stooge
 Share

Recommended Posts

I'm using the GUIListView package, specifically the _GUICtrlListViewSort function. I also have a listener that waits for a ListViewItem to be clicked, and displays the info on that ListViewItem in an Edit control.

When I look at the GUI it sure seems to do a great job.

Then I select any ListViewItem in the sorted ListView... and it isn't recognized. Nothing changes in my Edit control.

Situation A: Pre-sorting

I click on a ListViewItem and the Edit control updates instantly with the info on the Item.

I click on another ListViewItem and the Edit control updates instantly with the info on this different Item.

... repeat, repeat, repeat...

Then I sort...

Situation B: Post-sorting

I click on a ListViewItem and the Edit control remains unchanged from when I last sorted.

I click on another ListViewItem and the Edit control remains unchanged from when I last sorted.

What's going on?

Link to comment
Share on other sites

post code

Well GUIListView and its function _GUICtrlListViewSort are both standard issue for v3 beta.

as for how I call it....

Func _TM_SortViewList()
    $column2SortBy = GUICtrlGetState(@GUI_CtrlId)
    $target = @GUI_CtrlId
    _GUICtrlListViewSort ($target, 0, $column2SortBy)
    GUISetState(@SW_SHOW, "Guest-Tek TestMaster")
    Return 0
EndFunc ;==>_TM_SortViewList

and as for getting the info...

Func _TM_TemplateViewActionValues($itemSelected)
    $focusAction = $itemSelected
    $focusActData = StringSplit(GUICtrlRead($focusAction), "|")
    if _TM_ActionGet($focusActData[1]) == 0 or $focusActData[0] == 0 then return 0
    
    GUICtrlSetData($VregE[3], "Name: "&$VRegA[0]&"   Type: "&$VRegA[1]&@CRLF&"Screenshots: {")
    if $VRegA[2] then GUICtrlSetData($VregE[3], " Before", 1)
    if $VRegA[3] then GUICtrlSetData($VregE[3], " After", 1)
    if $VRegA[4] then GUICtrlSetData($VregE[3], " onerror", 1)

    GUICtrlSetData($VregE[3], " }"&@CRLF&"URL: ["&$VregA[5]&"]->["&$VregA[6]&"]"&@CRLF&"Inputs: {", 1)
    for $i = 0 to UBound($VRegB)-1 
        $ActInpString = StringSplit($VRegB[$i], "|")
        GUICtrlSetData($VRegE[3], @CRLF&" "&$ActInpString[1]&"("&$ActInpString[2]&") = '"&$ActInpString[3]&"'",1)
    Next
    GUICtrlSetData($VRegE[3], "}"&@CRLF&"Data: {",1)
    
    for $i = 0 to UBound($VRegC)-1 
        $ActDatString = StringSplit($VRegC[$i], "|")
        GUICtrlSetData($VRegE[3], @CRLF&" "&$ActDatString[1]&"("&$ActDatString[2]&") = '"&$ActDatString[3]&"'",1)
    Next
    GUICtrlSetData($VRegE[3], "}",1)
    
EndFunc
Edited by QA Stooge
Link to comment
Share on other sites

I wrote the sort, but I'll still need a script to test and see what is wrong.

Excellent. Script attached.

The functions to keep an eye on are the ones I posted earlier.

It's alot to look at, I know... almost 1k lines.

Keep in mind that $VRegE sort of holds the ListView control IDs to facilitate some flexibility while using GUIOnEventMode enabled. This makes multiple GUIs, so I figure using "msg = " method would get even more cluttery than this.

I do not pretend that this is exceptionally clean, pretty or even efficient. I'm just trying to get functionality.

I have a feeling the problem has to do with control IDs for the ListViewItems.

To test it, just make a few "Actions" with the "Add Action" button. I recommend mixing blank actions (just a name, no data) with actions that are tests, have input & data and the like. Once you have a few (I usually test with around 3-5) I start sorting and clicking to see if the Edit control updates.

Test_Chooser.au3

Edited by QA Stooge
Link to comment
Share on other sites

Auto-It Help File says... v3.1.1.101 (beta)

GUIListView script says... 3.1.1++

Here are the latest Changelog entries in my version. 1.47 is the last, and 1.43 is the last that has a ViewItem-based modification. The most recent file in Include (that I didn't change) was INet.au3... 1/10/2006

==ChangeLog==

1.47 (30 December 2005)

- Fixed _DateTimeFormat() to return LongTime notation for $sType=0 as specified in the Helpfile. (JdeB)

- Made Subject and Body optional in _InetSmtpMail(). (PartyPooper)

1.46 (21 December 2005)

- Fixed doc for _FileReadToArray(). (LxP)

- Fixed doc and Example for _ArraySearch. (Knight)

- Fixed _ArraySearch return value in case not found to -1. (SolidSnake)

- Added _InetSmtpMail to Inet.au3. (Walkabout)

1.45 (2 December 2005)

- Fixed _PathSplit(). Changed Dim $array[5] to Local $array[5]. (LxP)

- Updated _InetGetSource(), Remove stripping last character in return string. (w0uter)

- Fixed return value in _GUICtrlTreeViewDeleteItem when item id passed in. (gafrost)

- Updated GUI UDFs: Update Includes and Templates for use with external controls

Meaning controlID for autoit control, control hWnd for external control

Also replace all Dim statements with Local. (gafrost)

1.44 (25 November 2005)

- Fixed _ReplaceStringInFile to avoid adding CRLF when missing at the EOF. (JdeB)

- Added _ProcessGetName to Process.au3. (Erifash)

1.43 (18 November 2005)

- Fixed _DateAdd() Typo's in helpfile. (Gene)

- Updated _INetMail() with new logic to support environment variables. (JPM)

- Updated _GUICtrlListViewDeleteItemsSelected() with Test for Array. (CatchFish)

- Added a Constant to GUIList.au3 and changed all examples. (gafrost)

... hope that helps clear things up.

EDIT: Also note that there was originally an issue with the Sorting Function in that the boolean variable (well, really an int where 0=false and 1=true) passed to the function was ByRef, where the actualy listview was direct. Caused a few errors until I just changed how I called the function.

Please note that GUIListView's latest date was quite recent. I tried changing the inputs (so that the ListView was called ByRef instead of the boolean) to the sort function in question but it didn't help me any, so I changed it back. Thus it's at the original state, but the modified date is different.

Edited by QA Stooge
Link to comment
Share on other sites

Well I did that. Now I'm getting

C:\Documents and Settings\qa\Desktop\Test Chooser.au3 (199) : ==> Expected a variable in user function call.: 
_GUICtrlListViewSort ($target, 0, $column2SortBy) 
_GUICtrlListViewSort ($target, ^ ERROR

I'm curious.... the function header...

Func _GUICtrlListViewSort($h_listview, ByRef $v_descending, $i_sortcol, $s_Title = "", $s_text = "")

... has a boolean value ($v_descending) by reference? Should the listview itself not be ByRef? I removed the ByRef portion and now I don't get the error. Intuitively I think the ByRef belongs with the $h_listview variable (so I changed it to that), since that variable seems to be updated by the function (and I'm not getting the updated instance back).

... as a result, I'm still getting the same problem: The sort works, but all the ListViewItems are no longer accessable by anything but the the _GUICtrlListViewSort. Can't delete (like I can before sorting) or select & view the details (like I can before the sorting).

I'm pretty sure it's because of the following function...

Func _TM_SortViewList()
    $column2SortBy = GUICtrlGetState(@GUI_CtrlId)
    $target = @GUI_CtrlId
    _GUICtrlListViewSort ($target, 0, $column2SortBy)
    Return 0
EndFunc;==>_TM_SortViewList
... is called with GUIEventMode style...

GUICtrlSetOnEvent($fnList, "_TM_SortViewList")

And I can't send GUI_CtrlId as a direct variable or it blows up on me.

Edited by QA Stooge
Link to comment
Share on other sites

I was taking a closer look at the _GUICtrlListViewSort function.

I can't find any handling of control IDs for the ListViewItems.

Could it be that the function only sorts and writes the items' text while deleting the items themselves?

The fact that my ListView tables are multi-column might also make a difference.

EDIT:

I have an idea!!!!!!

Do you know how to make a variation on your _GUICtrlListViewGetNextItem which returns the ListViewItem's Control ID instead of the index? Or how to modify _GUICtrlListViewGetNextItem to get that? With that I can just make my own customs sorting.

Even better would be like a _GUICtrlListViewGetCtrlIDByIndex($lv_CtrlID, $i_index = 1) or even a _GUICtrlListViewGetCtrlIDArray($lv_CtrlID) would work nicely.

Edited by QA Stooge
Link to comment
Share on other sites

Never mind.

I just decided to be inspired by my Assembly days and make a "Control ID Array Register". Then I can sort, check what control ID and what type and stuff was clicked, and so forth. Should bypass the whole problem, it'll just take work instead of patience.

Edited by QA Stooge
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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