GUICtrlCreateList aktion bei Element anklicken

  • Hi,

    hab ein sehr simples Script bei dem aus einer ini einfach alle Sections ausgelesen werden und in ein GUICtrlCreateList gesteckt werden. Nun würde ich aber gerne beim klick auf einen Eintrag im Listview den Text der dort steht in eine Variable speicher. Jemand eine Idee wie man das machen könnte?

    mfg

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

    Einmal editiert, zuletzt von chip (28. November 2011 um 15:46)

  • Spoiler anzeigen
    [autoit]

    #include <APIConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListBox.au3>
    #include <ListBoxConstants.au3>
    #region - Timestamp
    ;2011-11-28 14:47:30
    #endregion - Timestamp

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

    #region - GUI Create
    GUICreate('', 500, 500)
    $iList = GUICtrlCreateList("bla", 4, 4)
    GUICtrlSetData(-1, "blub")
    GUISetState()
    #endregion - GUI Create
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    Global $hList = GUICtrlGetHandle($iList)
    Global $sItem = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    #region - GUI SelectLoop
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    WEnd
    #endregion - GUI SelectLoop
    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList)
    $hWndFrom = $ilParam
    $iCode = BitShift($iwParam, 16)
    Switch $hWndFrom
    Case $hList, $hWndList
    Switch $iCode
    Case $LBN_SELCHANGE
    $sCurrent = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    If $sCurrent <> $sItem Then
    $sItem = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    ConsoleWrite($sItem & @CRLF)
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]
  • Funktioniert leider nicht wenn ich mit GUICTRLSetData die Daten einfüge:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiListBox.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>
    #region - Timestamp
    ;2011-11-28 14:47:30
    #endregion - Timestamp

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

    #region - GUI Create
    GUICreate('', 500, 500)
    $iList = GUICtrlCreateList("", 4, 4)
    $programme = IniReadSectionNames("programm.ini")
    For $i = 1 To $programme[0]
    GUICtrlSetData($iList, $programme[$i])
    Next
    GUISetState()

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

    #endregion - GUI Create
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    Global $hList = GUICtrlGetHandle($iList)
    Global $sItem = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    #region - GUI SelectLoop
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    WEnd
    #endregion - GUI SelectLoop
    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList)
    $hWndFrom = $ilParam
    $iCode = BitShift($iwParam, 16)
    Switch $hWndFrom
    Case $hList, $hWndList
    Switch $iCode
    Case $LBN_SELCHANGE
    $sCurrent = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    If $sCurrent <> $sItem Then
    $sItem = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    ConsoleWrite($sItem & @CRLF)
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiListBox.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>
    #region - Timestamp
    ;2011-11-28 15:34:59
    #endregion - Timestamp

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

    #region - GUI Create
    GUICreate('', 500, 500)
    $iList = GUICtrlCreateList("", 4, 4)
    ;$aProgramme = IniReadSectionNames("programm.ini")
    Dim $aProgramme[5] = [4, "a", "b", "c", "d"]
    For $i = 1 To $aProgramme[0]
    GUICtrlSetData($iList, $aProgramme[$i])
    Next
    GUISetState()

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

    #endregion - GUI Create
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    Global $hList = GUICtrlGetHandle($iList)
    Global $sItem = ""
    #region - GUI SelectLoop
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    WEnd
    #endregion - GUI SelectLoop
    Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList)
    $hWndFrom = $ilParam
    $iCode = BitShift($iwParam, 16)
    Switch $hWndFrom
    Case $hList, $hWndList
    Switch $iCode
    Case $LBN_SELCHANGE
    $sCurrent = _GUICtrlListBox_GetText($hList, _GUICtrlListBox_GetCurSel($hList))
    If $sCurrent <> $sItem Then
    $sItem = $sCurrent
    ConsoleWrite($sItem & @CRLF)
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_COMMAND

    [/autoit]