badapple89 Posted November 7, 2013 Posted November 7, 2013 Hi guys, sure this is an easy one (maybe not) I have a single button and two lists. When I press the button I want to get the info of the last item that was selected. Is there any way to pass the handle of the listview with the last selected item to _GUICtrlListView_GetSelectedIndices. Im terrible at explaining things, so let me know if I need more clarification. Regards
Moderators Melba23 Posted November 7, 2013 Moderators Posted November 7, 2013 badapple89,This does what you want:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <GuiListView.au3> Global $hLV_Sel $hGUI = GUICreate("Test", 500, 500) $cLV_1 = GUICtrlCreateListView("List 1", 10, 10, 230, 200) For $i = 0 To 9 GUICtrlCreateListViewItem("Item 1" & $i, $cLV_1) Next $cLV_2 = GUICtrlCreateListView("List 2", 260, 10, 230, 200) For $i = 0 To 9 GUICtrlCreateListViewItem("Item 2" & $i, $cLV_2) Next $cButton = GUICtrlCreateButton("Last Selected", 10, 300, 100, 30) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $iIndex = _GUICtrlListView_GetSelectedIndices($hLV_Sel) $sText = _GUICtrlListView_GetItemText($hLV_Sel, $iIndex) MsgBox($MB_SYSTEMMODAL, "Last selection", $sText) EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate($tagNMHDR, $lParam) ; struct;hwnd hWndFrom;uint_ptr IDFrom;int Code;endstruct If @error Then Return Switch DllStructGetData($tStruct, "Code") Case $NM_CLICK $hLV_Sel = DllStructGetData($tStruct, "hWndFrom") EndSwitch EndFuncI think the code is clear enough to follow, but please do ask if you have any 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
badapple89 Posted November 8, 2013 Author Posted November 8, 2013 It does! I didn't have <MsgBoxConstants.au3> though. Is this standard :S but copied the _WM_NOTIFY into my script and its working all good. DLL stuff in AutoIt is pretty confusing, is there any good wiki's or something on it? Also is there any documentation that contains more about the Windows Message Codes I know of the autoit help file that lists the messages and codes. But I want to know things like what $WM_NOTIFY actually IS! Guess this is more a windows question than AutoIT? Thanks again for the help.
mikell Posted November 8, 2013 Posted November 8, 2013 For unfortunate people who prefer keep on running the last stable 3.3.8.1 instead of the beta (as it's still a beta) this $MB_SYSTEMMODAL is really a plague I modestly suggest not to use it in example scripts until the beta becomes the release
Moderators Melba23 Posted November 8, 2013 Moderators Posted November 8, 2013 mikell,"Plague" is a bit strong! All we are doing is keeping guinness happy! I usually use Constants.au3 in examples as that is where the constants are hidden in 3.3.8.1 but I sometime forget - I will try to do better in future. badapple89,I recommend the GUIRegisterMsg tutorial in the Wiki if you would like to learn more about Windows messages. 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
mikell Posted November 8, 2013 Posted November 8, 2013 mikell, "Plague" is a bit strong! All we are doing is keeping guinness happy! Oh... I'm quite able to understand this Though an unknown constant *is* a true plague when the corresponding include is unfindable Thus thank you for the info about Constants.au3 - I didn't know this
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