SumTingWong Posted November 15, 2005 Share Posted November 15, 2005 (edited) Could someone run this code in beta 87 and confirm the results I am getting? ListView is multi-select so select a few items before clicking on Test.#include <GUIConstants.au3> Dim $lviTestItems[10] GUICreate("MyGUI", 200, 400) $lvTest = GUICtrlCreateListView("Header1", 20, 20, 160, 320, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT)) For $i = 0 To 9 $lviTestItems[$i] = GUICtrlCreateListViewItem("Test " & $i, $lvTest) Next $btnTest = GUICtrlCreateButton("Test", 20, 360, 80, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnTest For $i = 0 To 9 $aItem = GUICtrlRead($lviTestItems[$i], 1) ConsoleWrite($aItem[0] & "," & $aItem[1] & @LF) Next EndSelect WEnd GUIDelete()This is what I am getting:Test 0,-1 Test 1,-1 Test 2,-1 Test 3,-1 Test 4,-1 Test 5,-1 Test 6,-1 Test 7,-1 Test 8,-1 Test 9,-1According to the help file:In 'advanced' mode the return value is a two-dimensional array.The second element of this value contains the same value like given in the default-table.The first element contains additional data of the control (see below).From the results I am getting, 2 things are wrong. Firstly, ListViewItem needs to be added to the default table as follows:ListViewItem State of the ListViewItemAlso, change the ListViewItem entry in the Remarks section to say The text of the ListViewItemSecond, the state value is always -1 regardless of whether the item is selected or not. Edited November 15, 2005 by SumTingWong Link to comment Share on other sites More sharing options...
tonedeaf Posted November 16, 2005 Share Posted November 16, 2005 (edited) From the results I am getting, 2 things are wrong. Firstly, ListViewItem needs to be added to the default table as follows:Also, change the ListViewItem entry in the Remarks section to say The text of the ListViewItemThat's correct. GUICtrlRead() when applied to a ListView Item:Normal mode - returns the text of ListView ItemAdvanced Mode - two dimensional array: Array[0] = Text of ListView Item, Array[1] = State of ListView Item.Second, the state value is always -1 regardless of whether the item is selected or not.The state table dosen't have any state value for Selected/UnselectedState Comments No Change 0 $GUI_UNCHECKED Radio or Checkbox will be unchecked $GUI_CHECKED Radio or Checkbox will be checked $GUI_INDETERMINATE Checkbox having the tristate attribute will be greyed $GUI_AVISTART Avi control will start playing $GUI_AVISTOP Avi control will stop playing $GUI_AVICLOSE Avi control will stop playing and release resource $GUI_ACCEPTFILES Input or Edit control will accept drag and drop of files $GUI_SHOW Control will be visible. On Tabitem control will select the first tab to be displayed $GUI_HIDE Control will not be visible $GUI_ENABLE Control will be enabled $GUI_DISABLE Control will be greyed out $GUI_FOCUS Control will be given input/selected focus $GUI_DEFBUTTON Control will be set as the default button on the window $GUI_EXPAND TreeViewItem will expand it's child items.To know which items user has selected/unselected, an alternate methord is to use $LVS_EX_CHECKBOXES extended list view style.You can change the GuiCtrlCreateListView line in your script to:$lvTest = GUICtrlCreateListView("Header1", 20, 20, 160, 320, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT), $LVS_EX_CHECKBOXES)and the script output would be:Test 0,4Test 1,4Test 2,1Test 3,4Test 4,1Test 5,4Test 6,1Test 7,4Test 8,4Test 9,4In this test run I checked items 2, 4 and 64 means items is unchecked = $GUI_UNCHECKED1 means item is checked = $GUI_CHECKED Edited November 16, 2005 by tonedeaf Link to comment Share on other sites More sharing options...
jpm Posted November 16, 2005 Share Posted November 16, 2005 @tonedeaf Perfect diagnosis. I don't know why Holger introduce this state which is irrelevant when you do not use $LVS_EX_CHECKBOXES The doc is a little missleading on this subject Link to comment Share on other sites More sharing options...
Holger Posted November 16, 2005 Share Posted November 16, 2005 Yeah, I see. What about these return values: 0 - item is unselected $GUI_FOCUS : item is selected $GUI_CHECKED : item is checked (with LVS_EX_CHECKBOXES-style) $GUI_CHECKED + $GUI_FOCUS : item is checked and selected $GUI_UNCHECKED : item is unchecked $GUI_UNCHECKED + $GUI_FOCUS : item is unchecked and selected What do you think? So long Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
SumTingWong Posted November 16, 2005 Author Share Posted November 16, 2005 Yeah, I see.What about these return values:0 - item is unselected$GUI_FOCUS : item is selected$GUI_CHECKED : item is checked (with LVS_EX_CHECKBOXES-style)$GUI_CHECKED + $GUI_FOCUS : item is checked and selected$GUI_UNCHECKED : item is unchecked$GUI_UNCHECKED + $GUI_FOCUS : item is unchecked and selectedWhat do you think?So long Holger Makes sense to me. At the moment, without resorting to using checkboxes as suggested, I am having to use ControlListView to enumerate selected items. Link to comment Share on other sites More sharing options...
jpm Posted November 17, 2005 Share Posted November 17, 2005 Yeah, I see.What about these return values:0 - item is unselected$GUI_FOCUS : item is selected$GUI_CHECKED : item is checked (with LVS_EX_CHECKBOXES-style)$GUI_CHECKED + $GUI_FOCUS : item is checked and selected$GUI_UNCHECKED : item is unchecked$GUI_UNCHECKED + $GUI_FOCUS : item is unchecked and selectedWhat do you think?So long HolgerI prefer to introduce $GUI_SELECTED not to confuse with real focus in case of for the future Link to comment Share on other sites More sharing options...
Holger Posted November 17, 2005 Share Posted November 17, 2005 (edited) @jpm: good idea so we have then the following states: 0 - No change $GUI_FOCUS : item is selected and listview parent windows gets focus $GUI_SELECTED : item is selected $GUI_CHECKED : item is checked $GUI_UNCHECKED : item is unchecked So the state could be a combination of these values. I also will add/change this for the treeview control, for the tab items I will see. So long.... Edited November 17, 2005 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
phillip123adams Posted May 23, 2006 Share Posted May 23, 2006 @jpm: good idea so we have then the following states:0 - No change$GUI_FOCUS : item is selected and listview parent windows gets focus$GUI_SELECTED : item is selected$GUI_CHECKED : item is checked$GUI_UNCHECKED : item is uncheckedSo the state could be a combination of these values.I also will add/change this for the treeview control, for the tab items I will see.So long.... Phillip Link to comment Share on other sites More sharing options...
phillip123adams Posted May 23, 2006 Share Posted May 23, 2006 @jpm: good idea so we have then the following states:0 - No change$GUI_FOCUS : item is selected and listview parent windows gets focus$GUI_SELECTED : item is selected$GUI_CHECKED : item is checked$GUI_UNCHECKED : item is uncheckedSo the state could be a combination of these values.I also will add/change this for the treeview control, for the tab items I will see.So long....What happened to $GUI_SELECTED? I do not see it in GuiConstants.Au3 or a value returned for it when a List View Item is selected. A forum search for $GUI_SELECTED returns only this thread. Phillip Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now