ListView Doppelklick

    • Offizieller Beitrag

    Hi,
    schau dir mal in der Hilfe die Funktion

    [autoit]

    _GUICtrlListBox_GetSelItems

    [/autoit]


    an.

    Ist es das was du suchst?

    MfG
    Der_Doc

    Wie willst du damit einen Doppelklick abfragen?

    • Offizieller Beitrag

    @Vor"Redner" :) - Von ListBox war nicht die Rede, sondern von Listview. ;)

    Und nun mal noch ein Bsp. ;)
    Du brauchst nicht alle Parameter, die in $tInfo enthalten sind. Habe sie der Vollständigkeit alle angeführt.
    Damit ein Klick/Doppelklick auch die richtige Spalte verwertet, ist der Style $LVS_EX_FULLROWSELECT notwendig.

    Spoiler anzeigen
    [autoit]

    #include <ListViewConstants.au3>
    #include <StructureConstants.au3>
    #include<GUIConstantsEx.au3>
    #include<WindowsConstants.au3>
    #include <GUIListView.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate('test')
    $ListView = GUICtrlCreateListView('Spalte1|Spalte2', 10, 10, 300, 200, -1, BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_TRACKSELECT))
    $hListView = GUICtrlGetHandle($ListView)
    _GUICtrlListView_SetColumnWidth($hListView, 0, 146)
    _GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
    For $i = 1 To 10
    GUICtrlCreateListViewItem('Zeile ' & $i & ' Spalte 1|Zeile ' & $i & ' Spalte 2', $ListView)
    Next
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _LeftDblClick($aInfo)
    Local $sMsg = 'Doppelklick auf:' & @LF & 'ZeilenIndex: ' & $aInfo[3] & @LF & _
    'Spaltenindex: ' & $aInfo[4] & @LF & _
    'Zellen Text: ' & _GUICtrlListView_GetItemText($hListView, $aInfo[3], $aInfo[4])
    MsgBox(0, 'Doppelklick', $sMsg)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    [/autoit] [autoit][/autoit] [autoit]

    $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_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    Local $aInfo[12] = [$hWndFrom, _
    $iIDFrom, _
    $iCode, _
    DllStructGetData($tInfo, "Index"), _
    DllStructGetData($tInfo, "SubItem"), _
    DllStructGetData($tInfo, "NewState"), _
    DllStructGetData($tInfo, "OldState"), _
    DllStructGetData($tInfo, "Changed"), _
    DllStructGetData($tInfo, "ActionX"), _
    DllStructGetData($tInfo, "ActionY"), _
    DllStructGetData($tInfo, "lParam"), _
    DllStructGetData($tInfo, "KeyFlags")]
    _LeftDblClick($aInfo)
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]