scila1996 Posted October 11, 2015 Share Posted October 11, 2015 I find this function and a example it's #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> Example() Func Example() Local $hImage, $idListview ; Create GUI GUICreate("ListView Add Item", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>ExampleBut i don't know how to add code to take event when click a item, Examle if me click to "Row 1: Col 1" item, it'll show Msgbox(...) Thank you very much ! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2015 Moderators Share Posted October 11, 2015 scila1996,You can do it like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; Set flag to indicate double click $fDblClk = False ; Row Col values Global $iRow, $iCol ; Create GUI $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 1 |Col 2 ", 10, 10, 200, 200) For $i = 0 To 19 GUICtrlCreateListViewItem("Item " & $i & "-0|Sub " & $i & "-1", $cLV) Next GUISetState() ; Register NOTIFY messages GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If the ListView was clicked If $fDblClk = True Then ; Announce where MsgBox($MB_SYSTEMMODAL, "", "You double-clicked the ListView:" & @CRLF & "Row" & @TAB & $iRow & @CRLF & "Col" & @TAB & $iCol) ; Reset the flag $fDblClk = False EndIf WEnd ; React to NOTIFY messages Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return ; Is it our ListView that has been actioned? If DllStructGetData($tStruct, 1) = GUICtrlGetHandle($cLV) Then ; Was it a double click? If DllStructGetData($tStruct, 3) = $NM_DBLCLK Then ; Set the flag $fDblClk = True ; And the values $iRow = DllStructGetData($tStruct, 4) $iCol = DllStructGetData($tStruct, 5) EndIf EndIf $tStruct = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFYIt does not matter which function you use to fill the list view- it will still work uisng _GUICtrlListView_AddItem.Please ask if you have any questionsM23 scila1996 1 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...
scila1996 Posted October 11, 2015 Author Share Posted October 11, 2015 (edited) Thank you M23, But it's not working, i'm click but it's not show Msgbox or to do something ! Edited October 11, 2015 by scila1996 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2015 Moderators Share Posted October 11, 2015 scila1996,i'm click but it's not show Msgbox or to do something !You need to double click - ListViews have a habit of eating single clicks.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...
scila1996 Posted October 11, 2015 Author Share Posted October 11, 2015 Really is it' not working :(, Hi Melba23you only give me knows method to get event when click to elements of the List View Thank you for help me ! I'am vietnamese so may be i statement not expect ! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2015 Moderators Share Posted October 11, 2015 scila196,Well, it works for me - so I cannot really offer any suggestions as to why it it does not do so for you. Are you running the code exactly as I posted?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...
scila1996 Posted October 11, 2015 Author Share Posted October 11, 2015 I also don't knows why it's not working ! for me do question , which that way do not use GuiRegisterMsg ! 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