Sind in Listview auch die einzelnen Tabellenfeldern veränderbar (d.h. will Text eingeben)?

  • Ich möchte ein Skript schreiben um Dateinamen umzubenennen. In der GUI soll ein zweispaltiges Listview angezeigt werden, in dem man jeweils ein Zeichen, das durch ein anderes ersetzt werden soll, direkt eingeben/eintippen kann. Z.B. Ersetze "_" durch " ". Im Grunde suche ich eine bearbeitbare zweispaltige Liste oder Tabelle.

    In den Beispielen der Hilfedatei war dies nicht möglich. Wenn ja gibt es irgendwo Beispiele für die Syntax? Auch in den GUI_CONTROL_STYLE_APPENDIX hab nichts diesbezüglich gefunden. Gruss Jan

    Einmal editiert, zuletzt von janrenzlow (11. März 2008 um 07:35)

  • Ich will einfach jede Zelle wie in Excel anklicken und direkt in der Zelle den Inhalt eingeben und/oder bearbeiten können. Das obige UDF funktioniert nur bei den Zellen der ersten Spalte, Sobald Du eine Zelle einer anderen Spalte anklickst, geht die Funktion auch bei den Zellen der ersten Spalte verloren.

    Also, wenn Du die Tabelle


    A1 A2
    B1 B2


    hast, soll jede Zelle z.B. A1 zu
    bearbeiten sein, in dem man die Zelle mit Doppelklick anklickt und
    dadurch den Inhalt markiert, um ihn dann bearbeiten zu können. Eben wie
    in Excel. Gruss Jan

    Im Spoiler ist jenes UDF zu finden.

    Spoiler anzeigen


    #include <GuiConstantsEx.au3>
    #include <GuiListView.au3>
    #include <GuiStatusBar.au3>
    #include <GuiImageList.au3>

    Opt('MustDeclareVars', 1)

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

    Global $hListView

    Example_External()

    Func Example_External()
    Local $hImage, $GUI

    $GUI = GUICreate("(External) ListView Edit Label", 400, 300)
    $hListView = _GUICtrlListView_Create ($GUI, "", 2, 2, 394, 268, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    GUISetState()

    ; 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)

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

    ; 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)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Edit item 0 label with time out
    _GUICtrlListView_EditLabel ($hListView, 0)

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

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

    $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_BEGINLABELEDIT ; Start of label editing for an item
    Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
    _DebugPrint("$LVN_BEGINLABELEDIT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @LF & _
    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @LF & _
    "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @LF & _
    "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @LF & _
    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @LF & _
    "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @LF & _
    "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @LF & _
    "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @LF & _
    "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
    Return False ; Allow the user to edit the label
    ;Return True ; Prevent the user from editing the label
    Case $LVN_COLUMNCLICK ; A column was clicked
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    _DebugPrint("$LVN_COLUMNCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
    ; No return value
    Case $LVN_DELETEITEM ; An item is about to be deleted
    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
    _DebugPrint("$LVN_DELETEITEM" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
    ; No return value
    Case $LVN_ENDLABELEDIT ; The end of label editing for an item
    Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
    Local
    $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo,
    "TextMax") & "]", DllStructGetData($tInfo, "Text"))
    _DebugPrint("$LVN_ENDLABELEDIT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @LF & _
    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @LF & _
    "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @LF & _
    "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @LF & _
    "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @LF & _
    "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @LF & _
    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @LF & _
    "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @LF & _
    "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @LF & _
    "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @LF & _
    "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
    ; 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
    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
    "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
    ; No return value
    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)
    _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
    "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
    ; No return value
    Case $NM_KILLFOCUS ; The control has lost the input focus
    _DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; No return value
    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
    "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
    ;Return 1 ; not to allow the default processing
    Return 0 ; allow the default processing
    Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
    _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode & @LF & _
    "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
    "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
    "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
    "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
    "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
    "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
    "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
    "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
    "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
    ; No return value
    Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
    _DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; No return value
    Case $NM_SETFOCUS ; The control has received the input focus
    _DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; No return value
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
    "!===========================================================" & @LF & _
    "+======================================================" & @LF & _
    "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
    "+======================================================" & @LF)
    EndFunc ;==>_DebugPrint

    4 Mal editiert, zuletzt von janrenzlow (11. März 2008 um 12:29)