$LVN_ENDLABELEDITW Nachricht abfangen...

  • Hallo,

    möchte eine Listview machen, bei der man nur den ItemWert in der ersten Spalte ändern kann. Hab eine ListView mit dem Stil "$LVS_EDITLABELS" erstellt - welcher mir dies ermöglicht, nur habe ich keine Ahnung
    wie ich nun die eingegebenen Werte übernehmen kann, da ich schon seit ein paar stunden d. Suchens und Probierens :whistling: hinter mir habe, und noch immer nicht dahinter gekommen bin wie die Nachricht ($LVN_ENDLABELEDITW) abgefangen werden kann. ?(

    Vielleicht hat einer eine Idee von euch...

    PS:Anscheinend ist dies in C++ kein problem... man muss nur den Stil LVS_EDITLABELS angeben....

    Spoiler anzeigen
    Zitat

    Ich weiß wo dein Haus wohnt... 8o

  • Ist klar hatte ich schon gesehen, aber mir gefällt diese Methode mit der EditBox nicht.
    Und ausserdem sieht der Stil $LVS_EDITLABELS - Windows konformer aus als Bugfix´s Version.

    Der Ansatz mit der eigenen WM_NOTIFY Funktion ist jedoch sehr gut. Vielleicht kann mir jemand helfen mit diesem Ansatz zu arbeiten...?

    Spoiler anzeigen
    Zitat

    Ich weiß wo dein Haus wohnt... 8o

  • Ich habe dir mal das _GUICtrlListView_EditLabel-beispiel umgeschrieben (Doppelklick zum editieren)

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #include <WindowsConstants.au3>

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

    Opt('MustDeclareVars', 1)

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

    $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

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

    Global $hListView

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

    _Main()

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

    Func _Main()
    Local $hImage

    GUICreate("ListView Edit Label", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    _GUICtrlListView_SetUnicodeFormat($hListView, False)
    GUISetState()

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

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

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

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

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

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

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

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    EndFunc ;==>_Main

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

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $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 $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Start of label editing for an item
    Return False ; Allow the user to edit the label
    ;Return True ; Prevent the user from editing the label
    Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; The end of label editing for an item
    $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
    ; If Text is not empty, return True to set the item's label to the edited text, return false to reject it
    ; If Text is empty the return value is ignored
    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return True
    Return False
    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)
    If 0 = DllStructGetData($tInfo, "SubItem") Then _ ; Wenn auf das erste SubItem geklickt wird, dann wird bearbeitet
    _GUICtrlListView_EditLabel($hWndFrom, DllStructGetData($tInfo, "Index"))
    ; No return value
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]
  • Hab´s gerade selbst hinbekommen...
    Danke @progandy.... :thumbup:

    Hier mein Code:

    [autoit]


    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $Handle, $itemID, $itemind, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = GUICtrlGetHandle($Liste)

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

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $Handle = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $itemID = DllStructGetData($tNMHDR, "IDFrom")
    $itemind = DllStructGetData($tNMHDR, "Code")
    Switch $Handle
    Case $hWndListView
    Switch $itemind

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

    Case $LVN_BEGINLABELEDITW
    Return False

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

    Case $LVN_ENDLABELEDITW
    $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return True

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

    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]
    Spoiler anzeigen
    Zitat

    Ich weiß wo dein Haus wohnt... 8o