Ace08 Posted October 14, 2010 Share Posted October 14, 2010 (edited) uhm guys just want to know why is this happening when running the script with a list box i run the code GUICtrlRead($listview) that gives me a number of 0 that i understand since i still havn't choose one item in the list box but when i choose the 1st item it gives me a value of 4 instead of 1? oh and another thing is there a way to determine a controlid if i didn't assign it into a variable? say like this GUICtrlCreateListViewItem("item1|item2|item3", $listview) would the script know what items i am specifying? Edited October 14, 2010 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 14, 2010 Share Posted October 14, 2010 Try it this way.. GUICtrlRead(GUICtrlRead($listview)). - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Ace08 Posted October 14, 2010 Author Share Posted October 14, 2010 thanks somdcomputerguy for the reply i did that one too but that one gives the value of the listitem itself, what i would like to know is if i can get the controlid itself because what i would like to do is get the value in a listbox edit it then return it to the listbox.... would that be possible? Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 14, 2010 Moderators Share Posted October 14, 2010 Ace08,Firstly, you speak of List boxes, but use $listview as an identifier - List and ListView controls are very different beasts. As your problem seems to match the bahaviour of a ListView, I will assume that is what you mean. From the Help file page for GUICtrlRead:Return value:ListView - Control identifier (controlID) of the selected ListViewItem. 0 means no item is selectedNow run this script and look at the values you get as ControlIDs:#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hListView = GUICtrlCreateListView("Title", 10, 10, 480, 300) For $i = 1 To 4 $iControlID = GUICtrlCreateListViewItem($i, $hListView) ConsoleWrite("ListView item " & $i & " has a ControlID of " & $iControlID & @CRLF) Next $hButton = GUICtrlCreateButton("Read", 10, 350, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ConsoleWrite(GUICtrlRead($hListView) & @CRLF) EndSwitch WEndYou will see that the ControlID values are returned when you read the ListView with the button - just like the help file says. If you want to change the value of the item, just use GUICtrlSetData like this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hListView = GUICtrlCreateListView("Title ", 10, 10, 480, 300) For $i = 1 To 4 GUICtrlCreateListViewItem($i, $hListView) Next $hButton = GUICtrlCreateButton("Amend", 10, 350, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton GUICtrlSetData(GUICtrlRead($hListView), "New data") EndSwitch WEndAll clear? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ace08 Posted October 15, 2010 Author Share Posted October 15, 2010 (edited) Wow, thanks a lot Melba23 your example was the one im looking for so i can use this GUICtrlRead($hListView)as a controlid if i didn't placed it in a variable i was thinking before that it only returns the line number where the list items are placed ListView - Control identifier (controlID) of the selected ListViewItem. 0 means no item is selectedYes that is but when i choose the 1st item it gives me a value of 4 why? does the value 1~3 have another meaning in a listview? im still confused about this one. Edited October 15, 2010 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2010 Moderators Share Posted October 15, 2010 Ace08,A ControlID is actually the index of the control in AutoIt's internal array where all the controls created with the built-in commands are listed. Only those commands are listed here - if you use the UDFs to create controls, you will see that they return normal Windows handles, not ControlIDs. The first control you create always has the ControlID of 3 as you can see by adding this line to the script above: $hListView = GUICtrlCreateListView("Title", 10, 10, 480, 300) ConsoleWrite("ListView ControlID: " & $hListView & @CRLF) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<I assume that the first few elements of the internal array are taken up with items in the ever-present, but hidden, AutoIt window so that the first available element is #3.Any more questions M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ace08 Posted October 15, 2010 Author Share Posted October 15, 2010 Hi Melba23 you're up late Thanks for the info so that means it returns the controls you made in a gui like for example in your code i changed GUICtrlRead($hListView) to GUICtrlRead(8) and it gave me the value of a button since the button control was created 8th This one is very usefull for me thanks again because i want to read the entire contents of the listview so i wanted to know which control i will start and stop So far that would be my last question(until i get a new one ) Thanks for th help Work smarter not harder.My First Posted Script: DataBase 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