yucatan Posted November 11, 2010 Share Posted November 11, 2010 hello guys i wanne make a GUICtrlCreateListView but if i click on a item i wanne be able to typ in the field. how this can me done? Greetz Yucatan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11, 2010 Moderators Share Posted November 11, 2010 yucatan, This thread shows you how to do it. Come back if you have problems integrating the code into your script. M23 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...
yucatan Posted November 11, 2010 Author Share Posted November 11, 2010 (edited) yucatan, This thread shows you how to do it. Come back if you have problems integrating the code into your script. M23 yeah i'm having some truble to integrating my code. i use this code now expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flag to indicate double click in ListView Global $fDblClk = False $Gui = GUICreate("Test", 400, 250) ; This works with either type of ListView - just adjust the comment statements to change the type ;#cs $hListView = GUICtrlCreateListView("Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) GUICtrlCreateListViewItem("Item 1", $hListView) GUICtrlCreateListViewItem("Item 2", $hListView) GUICtrlCreateListViewItem("Item 3", $hListView) GUICtrlCreateListViewItem("Item 4", $hListView) ;#ce #cs $hListView = _GUICtrlListView_Create($Gui, "Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) _GUICtrlListView_AddItem($hListView, "Item 1",0) _GUICtrlListView_AddItem($hListView, "Item 2",2) _GUICtrlListView_AddItem($hListView, "Item 3",1) _GUICtrlListView_AddItem($hListView, "Item 4",3) #ce GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then $fDblClk = False If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EDITLabel($hListView, $iSelected) EndIf WEnd 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 $NM_DBLCLK $fDblClk = True Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then Return True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc i when i stop editing the field. i wanne execute some code. but now is my question. where should i put the code that i want to be executed? how can i use this code if i have 6 different listview in my gui? Edited November 11, 2010 by yucatan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11, 2010 Moderators Share Posted November 11, 2010 yucatan,I would use another flag to indicate that the editing had ended - something like this (look for the <<<<<<<<<<<< lines): expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flags to indicate: 1) double click in ListView 2) editing ended Global $fDblClk = False, $fEdited = False ; <<<<<<<<<<<<<<<<<<<<<<<<<<< $Gui = GUICreate("Test", 400, 250) $hListView = GUICtrlCreateListView("Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) GUICtrlCreateListViewItem("Item 1", $hListView) GUICtrlCreateListViewItem("Item 2", $hListView) GUICtrlCreateListViewItem("Item 3", $hListView) GUICtrlCreateListViewItem("Item 4", $hListView) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then $fDblClk = False If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hListView, $iSelected) EndIf ; Editing has ended so run the code If $fEdited Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<< $fEdited = False MsgBox(0, "Hi there", "A label was edited") EndIf WEnd 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 $NM_DBLCLK $fDblClk = True Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Return True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncThat way you get back from the message handler as soon as possible, which is always a good idea. M23 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...
yucatan Posted November 11, 2010 Author Share Posted November 11, 2010 (edited) yucatan, I would use another flag to indicate that the editing had ended - something like this (look for the <<<<<<<<<<<< lines): expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flags to indicate: 1) double click in ListView 2) editing ended Global $fDblClk = False, $fEdited = False ; <<<<<<<<<<<<<<<<<<<<<<<<<<< $Gui = GUICreate("Test", 400, 250) $hListView = GUICtrlCreateListView("Items", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) GUICtrlCreateListViewItem("Item 1", $hListView) GUICtrlCreateListViewItem("Item 2", $hListView) GUICtrlCreateListViewItem("Item 3", $hListView) GUICtrlCreateListViewItem("Item 4", $hListView) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then $fDblClk = False If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $iSelected = _GUICtrlListView_GetSelectedIndices($hListView) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hListView, $iSelected) EndIf ; Editing has ended so run the code If $fEdited Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<< $fEdited = False MsgBox(0, "Hi there", "A label was edited") EndIf WEnd 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 $NM_DBLCLK $fDblClk = True Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Return True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc That way you get back from the message handler as soon as possible, which is always a good idea. M23 how can i use this code if i have 6 different listview in my gui? how can i define and lokc the width of my listview items? how can i find out wich field had been edited? greetz yucatan Edited November 11, 2010 by yucatan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11, 2010 Moderators Share Posted November 11, 2010 yucatan,Did your mother never tell you to say "Please" and "Thank you" occasionally? Here is the code adjusted to work with 2 ListViews with headers which cannot be adjusted: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flags to indicate: 1) double click in ListView 2) editing ended Global $fDblClk = 0, $fEdited = False $hGUI = GUICreate("Test", 400, 250) $hListView_1 = GUICtrlCreateListView("Items", 2, 2, 196, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hLV_1_Handle = GUICtrlGetHandle(-1) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hLV_1_Handle))) ; Disable ListView header <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateListViewItem("Item 1", $hListView_1) GUICtrlCreateListViewItem("Item 2", $hListView_1) GUICtrlCreateListViewItem("Item 3", $hListView_1) GUICtrlCreateListViewItem("Item 4", $hListView_1) $hListView_2 = GUICtrlCreateListView("Items", 202, 2, 196, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hLV_2_Handle = GUICtrlGetHandle(-1) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hLV_2_Handle))) GUICtrlCreateListViewItem("Item 5", $hListView_2) GUICtrlCreateListViewItem("Item 6", $hListView_2) GUICtrlCreateListViewItem("Item 7", $hListView_2) GUICtrlCreateListViewItem("Item 8", $hListView_2) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then Switch $fDblClk ; Depending on the ListView clicked <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case 1 $iSelected = _GUICtrlListView_GetSelectedIndices($hLV_1_Handle) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hLV_1_Handle, $iSelected) Case 2 $iSelected = _GUICtrlListView_GetSelectedIndices($hLV_2_Handle) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hLV_2_Handle, $iSelected) EndSwitch $fDblClk = 0 EndIf If $fEdited Then $fEdited = False MsgBox(0, "Hi there", "A label was edited") EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hLV_1_Handle Switch $iCode Case $NM_DBLCLK $fDblClk = 1 ; Set the flag to indicate the ListView which was doubleclicked <<<<<<<<<<<<<<<<<<<<<<< Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True Return True EndIf EndSwitch Case $hLV_2_Handle Switch $iCode Case $NM_DBLCLK $fDblClk = 2 Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True Return True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncAdding the other 4 ListViews I leave as an exercise for the student - as my old maths master used to say! But if I had 6 ListViews to deal with, I would put the ListView handles into an array and so shorten the code significantly. Any other requests? M23 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...
yucatan Posted November 11, 2010 Author Share Posted November 11, 2010 (edited) yucatan, Did your mother never tell you to say "Please" and "Thank you" occasionally? Here is the code adjusted to work with 2 ListViews with headers which cannot be adjusted: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flags to indicate: 1) double click in ListView 2) editing ended Global $fDblClk = 0, $fEdited = False $hGUI = GUICreate("Test", 400, 250) $hListView_1 = GUICtrlCreateListView("Items", 2, 2, 196, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hLV_1_Handle = GUICtrlGetHandle(-1) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hLV_1_Handle))) ; Disable ListView header <<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateListViewItem("Item 1", $hListView_1) GUICtrlCreateListViewItem("Item 2", $hListView_1) GUICtrlCreateListViewItem("Item 3", $hListView_1) GUICtrlCreateListViewItem("Item 4", $hListView_1) $hListView_2 = GUICtrlCreateListView("Items", 202, 2, 196, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hLV_2_Handle = GUICtrlGetHandle(-1) ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hLV_2_Handle))) GUICtrlCreateListViewItem("Item 5", $hListView_2) GUICtrlCreateListViewItem("Item 6", $hListView_2) GUICtrlCreateListViewItem("Item 7", $hListView_2) GUICtrlCreateListViewItem("Item 8", $hListView_2) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then Switch $fDblClk ; Depending on the ListView clicked <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case 1 $iSelected = _GUICtrlListView_GetSelectedIndices($hLV_1_Handle) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hLV_1_Handle, $iSelected) Case 2 $iSelected = _GUICtrlListView_GetSelectedIndices($hLV_2_Handle) If $iSelected <> "" Then _GUICtrlListView_EditLabel($hLV_2_Handle, $iSelected) EndSwitch $fDblClk = 0 EndIf If $fEdited Then $fEdited = False MsgBox(0, "Hi there", "A label was edited") EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hLV_1_Handle Switch $iCode Case $NM_DBLCLK $fDblClk = 1 ; Set the flag to indicate the ListView which was doubleclicked <<<<<<<<<<<<<<<<<<<<<<< Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True Return True EndIf EndSwitch Case $hLV_2_Handle Switch $iCode Case $NM_DBLCLK $fDblClk = 2 Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True Return True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Adding the other 4 ListViews I leave as an exercise for the student - as my old maths master used to say! But if I had 6 ListViews to deal with, I would put the ListView handles into an array and so shorten the code significantly. Any other requests? M23 yeah i have some other requets. sorry i forgot to say thanks u this are my other requestst:) how can i define the width of my listview items? how can i find out wich field had been edited? Edited November 11, 2010 by yucatan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11, 2010 Moderators Share Posted November 11, 2010 yucatan,OK, last answer for today! You need to use the ListView UDF to get the row and column. So here you have 6 ListViews with 2 columns and I have used an array to store the handles as I suggested earlier. Only problem - you can only edit the first column. As far as I know that is the best you can do with the $LVS_EDITLABELS style. Here is the script:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Set flags to indicate: 1) double click in ListView, 2) editing ended Global $fDblClk = 0, $fEdited = False Global $sEdited_Cell = "" Global $aLV_Handles[7] $hGUI = GUICreate("Test", 600, 400) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Items", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "SubItems") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 150) _GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, $k, 1) Next Next Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then Local $aHit = _GUICtrlListView_SubItemHitTest($aLV_Handles[$fDblClk]) If $aHit[0] <> -1 Then If $aHit[1] Then MsgBox(0, "Hi there", "ListView " & $fDblClk & " : Row " & $aHit[0] + 1 & @CRLF & "is not editable") Else _GUICtrlListView_EditLabel($aLV_Handles[$fDblClk], $aHit[0]) $sEdited_Cell = "ListView " & $fDblClk & " : Row " & $aHit[0] + 1 & @CRLF & "has been edited" EndIf EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False MsgBox(0, "Hi there", $sEdited_Cell) $sEdited_Cell = "" EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i Case $LVN_BEGINLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Return False Case $LVN_ENDLABELEDITW Local $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", _ DllStructGetData($tInfo, "Text")) Local $sNewText = DllStructGetData($tBuffer, "Text") If StringLen($sNewText) Then $fEdited = True Return True EndIf EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFuncI will go and look at how we might edit other items - you try and work out what I have done! M23 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...
Moderators Melba23 Posted November 12, 2010 Moderators Share Posted November 12, 2010 yucatan,That was fun! You can thank smashly for this as it is his code I have modified - and you can thank me for my searching and integration efforts. With this version you are now able to edit all the items and subitems in the ListViews: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <GuiEdit.au3> Global $fDblClk = 0, $fEdited = 0 Global $hListView = 0, $hEdit, $hDC, $hBrush, $aHit Global $iListView_ID, $sItemText Global $aLV_Handles[7] Global $hGUI = GUICreate("Test", 600, 400) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Col 1", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_REPORT, $LVS_SINGLESEL, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "Col 2") _GUICtrlListView_AddColumn($hListView, "Col 3") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 60) _GUICtrlListView_SetColumnWidth($hListView, 1, 60) _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(64 + $k), 1) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(77 + $k), 2) Next Next Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then $hListView = $aLV_Handles[$fDblClk] $iListView_ID = $fDblClk $aHit = _GUICtrlListView_SubItemHitTest($hListView) If $aHit[0] <> -1 Then _Start_ItemEdit() EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False ConsoleWrite("ListView " & $iListView_ID & " : Row " & $aHit[0] + 1 & @CRLF & "has been altered" & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS _End_SubItemEdit() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Start_ItemEdit() $sItemText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]) Local $iLen = _GUICtrlListView_GetColumnWidth($hListView, $aHit[1]) Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aHit[0], $aHit[1]) Local $aPos = WinGetPos($hListView) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) _WinAPI_ScreenToClient($hGUI, $tPoint) Local $iEdit_X = DllStructGetData($tPoint, "X") + $aRect[0] Local $iEdit_Y = DllStructGetData($tPoint, "Y") + $aRect[1] $hEdit = _GUICtrlEdit_Create($hGUI, $sItemText, $iEdit_X + 6, $iEdit_Y, $iLen - 7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $iLen + 10) DllStructSetData($stRect, 2, 0) DllStructSetData($stRect, 3, 0) DllStructSetData($stRect, 4, 17) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) EndFunc Func _End_SubItemEdit() Local $sText = _GUICtrlEdit_GetText($hEdit) If $sText <> $sItemText Then _GUICtrlListView_SetItemText($hListView, $aHit[0], $sText, $aHit[1]) $fEdited = True EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $hListView = 0 EndFuncIs that everything you wanted? M23 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...
yucatan Posted November 15, 2010 Author Share Posted November 15, 2010 (edited) Hello, in your other sample i was able to push enter en then it saved my edit. what is the best say to implement this here? yucatan, That was fun! You can thank smashly for this as it is his code I have modified - and you can thank me for my searching and integration efforts. With this version you are now able to edit all the items and subitems in the ListViews: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <GuiEdit.au3> Global $fDblClk = 0, $fEdited = 0 Global $hListView = 0, $hEdit, $hDC, $hBrush, $aHit Global $iListView_ID, $sItemText Global $aLV_Handles[7] Global $hGUI = GUICreate("Test", 600, 400) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Col 1", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_REPORT, $LVS_SINGLESEL, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "Col 2") _GUICtrlListView_AddColumn($hListView, "Col 3") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 60) _GUICtrlListView_SetColumnWidth($hListView, 1, 60) _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(64 + $k), 1) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(77 + $k), 2) Next Next Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; If an item was double clicked If $fDblClk Then $hListView = $aLV_Handles[$fDblClk] $iListView_ID = $fDblClk $aHit = _GUICtrlListView_SubItemHitTest($hListView) If $aHit[0] <> -1 Then _Start_ItemEdit() EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False ConsoleWrite("ListView " & $iListView_ID & " : Row " & $aHit[0] + 1 & @CRLF & "has been altered" & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS _End_SubItemEdit() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Start_ItemEdit() $sItemText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]) Local $iLen = _GUICtrlListView_GetColumnWidth($hListView, $aHit[1]) Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aHit[0], $aHit[1]) Local $aPos = WinGetPos($hListView) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) _WinAPI_ScreenToClient($hGUI, $tPoint) Local $iEdit_X = DllStructGetData($tPoint, "X") + $aRect[0] Local $iEdit_Y = DllStructGetData($tPoint, "Y") + $aRect[1] $hEdit = _GUICtrlEdit_Create($hGUI, $sItemText, $iEdit_X + 6, $iEdit_Y, $iLen - 7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $iLen + 10) DllStructSetData($stRect, 2, 0) DllStructSetData($stRect, 3, 0) DllStructSetData($stRect, 4, 17) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) EndFunc Func _End_SubItemEdit() Local $sText = _GUICtrlEdit_GetText($hEdit) If $sText <> $sItemText Then _GUICtrlListView_SetItemText($hListView, $aHit[0], $sText, $aHit[1]) $fEdited = True EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $hListView = 0 EndFunc Is that everything you wanted? M23 Edited November 15, 2010 by yucatan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2010 Moderators Share Posted November 15, 2010 yucatan,I would use an Accelerator key - these are like HotKeys but only work within your app rather than on all running processes. You could code it like this - look for the <<<<<<<<<<<<<<< lines: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <GuiEdit.au3> Global $fDblClk = 0, $fEdited = False Global $hListView = 0, $hEdit, $hDC, $hBrush, $aHit Global $iListView_ID, $sItemText Global $aLV_Handles[7] Global $hGUI = GUICreate("Test", 600, 500) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Col 1", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_REPORT, $LVS_SINGLESEL, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "Col 2") _GUICtrlListView_AddColumn($hListView, "Col 3") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 60) _GUICtrlListView_SetColumnWidth($hListView, 1, 60) _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(64 + $k), 1) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(77 + $k), 2) Next Next Next $hEdit = GUICtrlCreateEdit("", 10, 410, 580, 80) ; Create dummy control for the accelerator to action $hAccel_Enter = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Set accelerator for Enter to use if editing Dim $aAccelKeys[1][2]=[["{ENTER}", $hAccel_Enter]] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hAccel_Enter ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _End_SubItemEdit() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch ; If an item was double clicked If $fDblClk Then $hListView = $aLV_Handles[$fDblClk] $iListView_ID = $fDblClk $aHit = _GUICtrlListView_SubItemHitTest($hListView) If $aHit[0] <> -1 Then _Start_ItemEdit() EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False ConsoleWrite("ListView " & $iListView_ID & " : Row " & $aHit[0] + 1 & @CRLF & "has been altered" & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS _End_SubItemEdit() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Start_ItemEdit() $sItemText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]) Local $iLen = _GUICtrlListView_GetColumnWidth($hListView, $aHit[1]) Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aHit[0], $aHit[1]) Local $aPos = WinGetPos($hListView) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) _WinAPI_ScreenToClient($hGUI, $tPoint) Local $iEdit_X = DllStructGetData($tPoint, "X") + $aRect[0] Local $iEdit_Y = DllStructGetData($tPoint, "Y") + $aRect[1] $hEdit = _GUICtrlEdit_Create($hGUI, $sItemText, $iEdit_X + 6, $iEdit_Y, $iLen - 7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $iLen + 10) DllStructSetData($stRect, 2, 0) DllStructSetData($stRect, 3, 0) DllStructSetData($stRect, 4, 17) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) ; Set acclerator key GUISetAccelerators($aAccelKeys) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc Func _End_SubItemEdit() Local $sText = _GUICtrlEdit_GetText($hEdit) If $sText <> $sItemText Then _GUICtrlListView_SetItemText($hListView, $aHit[0], $sText, $aHit[1]) $fEdited = True EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $hListView = 0 ; Clear accelerator key GUISetAccelerators(0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFuncThe edit control is just there so that you can see that the ENTER key works normally when you are not editing the ListView. M23 PixelGoodies 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...
yucatan Posted November 15, 2010 Author Share Posted November 15, 2010 Thanks alot! if i wanne change the data of the items in my list. during every 1 minit for example what is the best way to do this? yucatan, I would use an Accelerator key - these are like HotKeys but only work within your app rather than on all running processes. You could code it like this - look for the <<<<<<<<<<<<<<< lines: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <GuiEdit.au3> Global $fDblClk = 0, $fEdited = False Global $hListView = 0, $hEdit, $hDC, $hBrush, $aHit Global $iListView_ID, $sItemText Global $aLV_Handles[7] Global $hGUI = GUICreate("Test", 600, 500) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Col 1", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_REPORT, $LVS_SINGLESEL, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "Col 2") _GUICtrlListView_AddColumn($hListView, "Col 3") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 60) _GUICtrlListView_SetColumnWidth($hListView, 1, 60) _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(64 + $k), 1) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(77 + $k), 2) Next Next Next $hEdit = GUICtrlCreateEdit("", 10, 410, 580, 80) ; Create dummy control for the accelerator to action $hAccel_Enter = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Set accelerator for Enter to use if editing Dim $aAccelKeys[1][2]=[["{ENTER}", $hAccel_Enter]] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hAccel_Enter ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _End_SubItemEdit() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch ; If an item was double clicked If $fDblClk Then $hListView = $aLV_Handles[$fDblClk] $iListView_ID = $fDblClk $aHit = _GUICtrlListView_SubItemHitTest($hListView) If $aHit[0] <> -1 Then _Start_ItemEdit() EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False ConsoleWrite("ListView " & $iListView_ID & " : Row " & $aHit[0] + 1 & @CRLF & "has been altered" & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS _End_SubItemEdit() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Start_ItemEdit() $sItemText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]) Local $iLen = _GUICtrlListView_GetColumnWidth($hListView, $aHit[1]) Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aHit[0], $aHit[1]) Local $aPos = WinGetPos($hListView) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) _WinAPI_ScreenToClient($hGUI, $tPoint) Local $iEdit_X = DllStructGetData($tPoint, "X") + $aRect[0] Local $iEdit_Y = DllStructGetData($tPoint, "Y") + $aRect[1] $hEdit = _GUICtrlEdit_Create($hGUI, $sItemText, $iEdit_X + 6, $iEdit_Y, $iLen - 7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $iLen + 10) DllStructSetData($stRect, 2, 0) DllStructSetData($stRect, 3, 0) DllStructSetData($stRect, 4, 17) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) ; Set acclerator key GUISetAccelerators($aAccelKeys) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc Func _End_SubItemEdit() Local $sText = _GUICtrlEdit_GetText($hEdit) If $sText <> $sItemText Then _GUICtrlListView_SetItemText($hListView, $aHit[0], $sText, $aHit[1]) $fEdited = True EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $hListView = 0 ; Clear accelerator key GUISetAccelerators(0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc The edit control is just there so that you can see that the ENTER key works normally when you are not editing the ListView. M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2010 Moderators Share Posted November 15, 2010 yucatan, How are you getting the data in the first place when you create the ListViews? For example, are you reading from an array? M23 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...
yucatan Posted November 15, 2010 Author Share Posted November 15, 2010 yucatan,How are you getting the data in the first place when you create the ListViews? For example, are you reading from an array? M23 guictrlsetdata i think. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2010 Moderators Share Posted November 15, 2010 yucatan,guictrlsetdata i thinkWell, you think wrongly! _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem are used to populate UDF-created ListViews. But the data we use in these commands must come from somewhere. You talk of updating the data in the lists, from where do you get these updates? In what form is the new data delivered? M23 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...
yucatan Posted November 15, 2010 Author Share Posted November 15, 2010 from a mysql database. but its coming in a array.yucatan,Well, you think wrongly! _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem are used to populate UDF-created ListViews. But the data we use in these commands must come from somewhere. You talk of updating the data in the lists, from where do you get these updates? In what form is the new data delivered? M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2010 Moderators Share Posted November 15, 2010 yucatan,Then you need a TimerInit/TimerDiff loop or an Adlib function to read the new data from the array into the ListViews at the appropriate interval. I would strongly suggest that you use the _GUICtrlListView_DeleteAllItems command to remove all the existing items in the ListViews before you reload then with the new values. M23 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...
guinness Posted November 15, 2010 Share Posted November 15, 2010 Even though it's kind of off topic, Thanks ever so much for posting that Edit All Items in a ListView with the Enter Key, this is going in my useful Functions/Solutions (along with your Toast UDF & StringSize UDF! ) UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2010 Moderators Share Posted November 15, 2010 guinness, Glad you liked it! M23 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...
guinness Posted November 15, 2010 Share Posted November 15, 2010 If I don't see a post (with an example) from you within 24 hours I start to get worried You have directly/indirectly helped me understand a lot about AutoIt with your wiki/forum entries. Sometimes I think people take advantage of your kind nature and a thank you once in a while is just as good as an apple a day! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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