Jdop Posted March 9, 2010 Share Posted March 9, 2010 For some reason this is escaping me. The ControlID is created when GUICtrlCreateListViewItem() is called. No problem. I want to go back later in the code , after some manipulations to the listview, and change the text color on individual items. I can't seem to find how to retrieve the controlID programmatically when listview position is known. I need the controlID in order to change the color. I'm quite sure this can be done, but not having any luck divining the method. Link to comment Share on other sites More sharing options...
Beege Posted March 9, 2010 Share Posted March 9, 2010 I'm confused. Why can't you use the ctrlID returned from GUICtrlCreateListViewItem()? Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Jdop Posted March 9, 2010 Author Share Posted March 9, 2010 1) I'd have to store it for later use and there are multiple items (20 or 30) 2) I delete items from the original array, so I'd have to manipulate the stored pointers , adding to the complexity. There should be a way of getting the current controlID of a listitem. Link to comment Share on other sites More sharing options...
Fire Posted March 9, 2010 Share Posted March 9, 2010 (edited) Hi. For get selected item from Listview you can use: _GUICtrlListView_GetSelectedIndices($List1) Edited March 9, 2010 by Sh3llC043r [size="5"] [/size] Link to comment Share on other sites More sharing options...
Jdop Posted March 9, 2010 Author Share Posted March 9, 2010 Dont think so Sh3llC043r, I need the control ID not the index within the list. I thought this would be a simple one, guess not. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 9, 2010 Moderators Share Posted March 9, 2010 Jdop, Does this UDF help any? 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...
Yashied Posted March 9, 2010 Share Posted March 9, 2010 (edited) Jdop, As Beege said, you must use the ID that returns a GUICtrl... functions. Moreover, "ListItem" has no valid ID, it's effective only within AutoIt. Edited March 9, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Jdop Posted March 10, 2010 Author Share Posted March 10, 2010 Jdop, Does this UDF help any? M23 I thought that might be of help but it's overkill for my question and has some bugs when I tried to run it. Must be a way to easily retrieve the existing controlID of a listview item. Link to comment Share on other sites More sharing options...
wraithdu Posted March 10, 2010 Share Posted March 10, 2010 (edited) Really, no one knows this? Here ya go: #NoTrayIcon #include <GuiListView.au3> $gui = GUICreate("lvtest") $lv = GUICtrlCreateListView("column 1", 10, 10, 200, 200) ConsoleWrite("listview id: " & $lv & @CRLF & @CRLF) For $i = 1 To 10 ConsoleWrite("item" & $i & " id: " & GUICtrlCreateListViewItem("item" & $i, $lv) & @CRLF) Next $hlv = GUICtrlGetHandle($lv) ConsoleWrite(@CRLF & "hlv: " & $hlv & @CRLF & @CRLF & "================" & @CRLF) For $i = 0 To _GUICtrlListView_GetItemCount($hlv) - 1 ConsoleWrite("item" & $i + 1 & " param: " & _GUICtrlListView_GetItemParam($hlv, $i) & @CRLF) Next Edited March 10, 2010 by wraithdu Link to comment Share on other sites More sharing options...
Jdop Posted March 11, 2010 Author Share Posted March 11, 2010 (edited) I actually figured it out (I forget exactly how, probably looking at some of the code references posted here) last night , but you are quite correct, _GUICtrlListView_GetItemParam is the answer. It's one of those things , that if you don't work with the language all the time, you forget about, and it's not really intuitive based on the help file or the name. "Retrieves the application specific value of the item " Well, maybe you can figure out that means ControlID, but it's not all that clear. Thanks for all the input guys. Edited March 11, 2010 by Jdop Link to comment Share on other sites More sharing options...
wraithdu Posted March 11, 2010 Share Posted March 11, 2010 Yeah, it's not something any random person would know. I figured one of the other 'old timers' would have known this trick. I figued it out while working with the sorting functions for UDF created listview items. You have to specify the 'param' yourself or the sorting doesn't work. It's also where AutoIt stores it's 'control ID' for listview items. In real win32, listview items don't have control IDs. It's just an internal AutoIt thing so it can manage them for you. Link to comment Share on other sites More sharing options...
LeCarre Posted June 15, 2012 Share Posted June 15, 2012 Indeed I had this issue.I store the ControlID's in an array, but after sorting...Created ID's After Sorting ID's 10 12 11 10 12 11Clicking on the 1st ListView Item (after sorting) Returns Index of 1, my array containing ID's has a value of 10 in the first position.There is no way to use my array to find the CntrlID of the clicked item_GUICtrlListView_GetItemParam did the trick. But I felt compelled to explain how I fell into this rutStill wondering why there is not Internal Answer, but having to goto UDF's for this... Link to comment Share on other sites More sharing options...
sudeepjd Posted July 4, 2020 Share Posted July 4, 2020 I know this post is old, I came across is since I was looking for a solution to change the color of the items. I am creating the items with _GUICtrlListView_AddArray in most places in my program.. and manipulating the data by inserting new rows, deleting rows etc. So the UDF is a good option. The only way I could solve this problem was to recreate the items with the native GUICtrlCreateListItem and then use the _GUICtrlListView_GetItemParam to retreive the control ID. I hope this helps somebody who is also looking for the same answer. I dont know if there is a better way to do this.. But for me it works. ;Color the listview Func _GUICtrlListView_SetItemBkColor($hWnd, $Item_index, $Color_RGB) ;Assign ControlIDs to the ListView Items $cnt = _GUICtrlListView_GetItemCount($hWnd) Local $data[$cnt] For $i = 0 to $cnt-1 $data[$i] = _GUICtrlListView_GetItemTextString($hWnd, $i) Next _GUICtrlListView_DeleteAllItems($hWnd) For $i = 0 to $cnt-1 GUICtrlCreateListViewItem($data[$i], $hWnd) Next $ctrlID = _GUICtrlListView_GetItemParam($hWnd, $Item_index) GUICtrlSetBkColor($ctrlID, $Color_RGB) EndFunc ;==>_GUICtrlListView_SetItemBkColor Link to comment Share on other sites More sharing options...
Starky Posted August 22, 2022 Share Posted August 22, 2022 #include <GuiListView.au3> _GUICtrlListView_MapIndexToID ( $hWnd, $iIndex ) I know the post is old, but seeming as it was within the top 3 results on Google when I looked into this, I felt this needs to be in here. 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