drwoobie Posted August 29, 2008 Share Posted August 29, 2008 (edited) Hi all, I am stuck trying to figure out how to get the contents of ListViewItems with checkbox controls (to pass on to other functions). I've been looking at the forum, but I think I've confused myself even more. Here's my testing code: CODE #NoTrayIcon #include <GuiConstants.au3> #include <ListViewConstants.au3> ; GUI GuiCreate("list item select issue", 420, 400) $currentView = GuiCtrlCreateListView("Col A | Col B", 5, 26, 203, 275, -1, BitOR( $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) For $i = 1 To 3 GuiCtrlCreateListViewItem( "Item " & $i & "|" & "SubItem " & $i, $currentView) Next ; BUTTON $showMe = GuiCtrlCreateButton("Show Me", 5, 306, 65, 20) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $showMe MsgBox ( 4096, "Results", GUICtrlRead($currentView, 1)) EndSelect WEnd GUIDelete() Exit In all my testing of what I could find in the way of answers on the forum, the behavior of this code is the best result I have been able to manage. Selecting a "line" item and clicking the button causes the msgbox to display (I assume) the line item's place value (1st line shows value "4") etc. If I unselect a line and check a checkbox, the msgbox displays "0". My goal is to be able to select a checkbox and sending the corresponding information to the next function. What functions do I need to be looking at to get the functionality I want? Edited August 29, 2008 by drwoobie Thanks,drwoobieMy Projects:Network Drive Profile Tool Link to comment Share on other sites More sharing options...
Aceguy Posted August 29, 2008 Share Posted August 29, 2008 just a thing to point out...... when click the (show me button) your taking away the focus of the listview... [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Aceguy Posted August 29, 2008 Share Posted August 29, 2008 so to help you out... expandcollapse popup#include<GUIConstantsEx.au3> #include<ListViewConstants.au3> #include<StructureConstants.au3> #include<WindowsConstants.au3> #include<GuiListView.au3> Global $gui,$sel, $hListView ; GUI $gui=GuiCreate("list item select issue", 420, 400) $hListView = GuiCtrlCreateListView("Col A | Col B", 5, 26, 203, 275, -1, BitOR( $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) For $i = 1 To 3 GuiCtrlCreateListViewItem( "Item " & $i & "|" & "SubItem " & $i, $hListView) Next ; BUTTON $label = GUICtrlCreateLabel("RESULTS ARE HERE", 5, 306, 165, 20) GuiSetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 sleep(50) WEnd Exit Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $sel = DllStructGetData($tInfo, "Index") GUICtrlSetData($label, _GUICtrlListView_GetItemTextString($hListView,$sel)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
drwoobie Posted August 30, 2008 Author Share Posted August 30, 2008 so to help you out...Thank you aceguy. Your statement about the button taking the focus makes some very dim sense to me.Just looking at that code block, I can tell I have some studying ahead of me.Thanks for taking time to help me out. Thanks,drwoobieMy Projects:Network Drive Profile Tool Link to comment Share on other sites More sharing options...
Aceguy Posted August 30, 2008 Share Posted August 30, 2008 your welcome Anytime and Welcome to Autoit Just to point out, in order to use the button method, you could use a variable to save the last seleceted item, that way when you press the button, it reads from the $last_selected rather than the $listview. (if you really wanted the button method). [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock 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