rony2006 Posted March 8, 2021 Share Posted March 8, 2021 Hello, In my script i have 2 different listview and I need for each of them to trigger different functions for double click on listview item. expandcollapse popupFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ;~ Local $tBuffer $hWndListView = $lista_poze If Not IsHWnd($lista_poze) Then $hWndListView = GUICtrlGetHandle($lista_poze) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView if $iCode = $NM_DBLCLK Then $lapofilename = _GUICtrlListView_GetItemText($lista_poze, _GUICtrlListView_GetHotItem($lista_poze)) shellexecute(@ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename) EndIf if $iCode = $NM_CLICK Then $lapofilename = _GUICtrlListView_GetItemText($lista_poze, _GUICtrlListView_GetHotItem($lista_poze)) ;msgbox(0, "", $lapofilename) ;shellexecute(@ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename) GUICtrlSetImage($imagine, @ScriptDir & "\Dosare\" & GUICtrlRead($nr_inmatriculare) & "\Poze\Initiale\Resize\" & $lapofilename) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY This code works good for list $lista_poze but I have another list and I dont know how to integrate it in WM_notify. How can I make $hWndListView to accept 2 different listviews? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 8, 2021 Moderators Share Posted March 8, 2021 rony2006, The $hWndFrom and $hIDFrom parameters allow you to distinguish between the 2 ListViews. Just use a Switch structure to separate the different sections of the handler. M23 FrancescoDiMuro 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...
rony2006 Posted March 8, 2021 Author Share Posted March 8, 2021 Thanks, I found a working example for this and I adapted to my code: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Purple Sheets", 376, 550, -1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $ListViewExp = GUICtrlCreateListView("", 8, 16, 106, 382, $LVS_SHOWSELALWAYS) $ListViewLind = GUICtrlCreateListView("", 130, 16, 106, 382, $LVS_SHOWSELALWAYS) $ListViewScott = GUICtrlCreateListView("", 256, 16, 106, 382, $LVS_SHOWSELALWAYS) _GUICtrlListView_AddColumn($ListViewExp, "Expected", 85) _GUICtrlListView_AddColumn($ListViewLind, "Lindsey", 85) _GUICtrlListView_AddColumn($ListViewScott, "Scott", 85) _GUICtrlListView_AddItem($ListViewExp, "testing1", 0) _GUICtrlListView_AddItem($ListViewLind, "testing2", 0) _GUICtrlListView_AddItem($ListViewScott, "testing3", 0) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListViewExp)] GUISetState(@SW_SHOW) While 1 Sleep (100) Wend Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView1 = GUICtrlGetHandle($ListViewExp) $hWndListView2 = GUICtrlGetHandle($ListViewLind) $hWndListView3 = GUICtrlGetHandle($ListViewScott) ;~ If Not IsHWnd($ListViewExp) Then $hWndListView = GUICtrlGetHandle($ListViewExp) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView1 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewExp, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch Case $hWndListView2 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewLind, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch Case $hWndListView3 Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($ListViewScott, DllStructGetData($tInfo, "Index")) MsgBox (0, "you clicked on", $text) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Exit () Exit EndFunc 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