GUICtrlCreateListView
#1
Posted 11 November 2010 - 12:44 PM
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
#2
Posted 11 November 2010 - 02:21 PM
This thread shows you how to do it.
Come back if you have problems integrating the code into your script.
M23
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#3
Posted 11 November 2010 - 02:28 PM
yeah i'm having some truble to integrating my code.yucatan,
This thread shows you how to do it.
Come back if you have problems integrating the code into your script.![]()
M23
i use this code now
#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 by yucatan, 11 November 2010 - 02:35 PM.
#4
Posted 11 November 2010 - 02:39 PM
I would use another flag to indicate that the editing had ended - something like this (look for the <<<<<<<<<<<< lines):
#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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#5
Posted 11 November 2010 - 02:46 PM
yucatan,
I would use another flag to indicate that the editing had ended - something like this (look for the <<<<<<<<<<<< lines):![]()
AutoIt#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 by yucatan, 11 November 2010 - 03:02 PM.
#6
Posted 11 November 2010 - 03:11 PM
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:
#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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#7
Posted 11 November 2010 - 03:44 PM
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:![]()
AutoIt#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 by yucatan, 11 November 2010 - 03:50 PM.
#8
Posted 11 November 2010 - 04:44 PM
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:
#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 EndFunc
I will go and look at how we might edit other items - you try and work out what I have done!
M23
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#9
Posted 12 November 2010 - 03:08 PM
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:
#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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#10
Posted 15 November 2010 - 01:00 PM
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:
AutoIt#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 by yucatan, 15 November 2010 - 01:07 PM.
#11
Posted 15 November 2010 - 01:34 PM
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:
#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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#12
Posted 15 November 2010 - 01:41 PM
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:![]()
AutoIt#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
#13
Posted 15 November 2010 - 01:56 PM
How are you getting the data in the first place when you create the ListViews? For example, are you reading from an array?
M23
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#14
Posted 15 November 2010 - 02:06 PM
guictrlsetdata i think.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
#15
Posted 15 November 2010 - 02:14 PM
Well, you think wrongly! _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem are used to populate UDF-created ListViews.guictrlsetdata i think
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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#16
Posted 15 November 2010 - 02:28 PM
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
#17
Posted 15 November 2010 - 02:46 PM
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
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#18
Posted 15 November 2010 - 05:03 PM
Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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() • _StringIsValid() • _StringReplaceWholeWord() • _StringStripChar() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • AutoIt Search • AutoIt3 Portable • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasteBin • SciTE Jump • Signature Creator • WM_COPYDATA • More Examples...Updated: 11/04/2013
#19
Posted 15 November 2010 - 05:09 PM
Glad you liked it!
M23
Toast - Small GUIs which pop out of the Systray   Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI   NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure   Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
#20
Posted 15 November 2010 - 05:34 PM
Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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() • _StringIsValid() • _StringReplaceWholeWord() • _StringStripChar() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • AutoIt Search • AutoIt3 Portable • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasteBin • SciTE Jump • Signature Creator • WM_COPYDATA • More Examples...Updated: 11/04/2013
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users




