Moderators Melba23 Posted August 28, 2018 Author Moderators Posted August 28, 2018 robertocm, And it is not intended to do so. If you as the coder call the _EditItem function programmatically, you know that there should be a return and can deal with it at that point - _EventMonitor is there to tell you that something user-initiated has occurred and that your code need to react (or that the UDF needs to react if colour is involved). 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
Moderators Melba23 Posted August 29, 2018 Author Moderators Posted August 29, 2018 (edited) Tersion, This beta version of the UDF automatically returns focus to the ListView after an edit so you should be able to remove the robertocm "work-around" (hack!) to get the keys working again after an edit: Please let me know if it works for you as well as it does for me. M23 Edited September 3, 2018 by Melba23 Beta code removed 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
Tersion Posted August 29, 2018 Posted August 29, 2018 Melba23, YES! It's works on my test example exactly like robertocm "work-around". Thanks for that fix! May I ask you, when these last fixes would be added to main release of GUIListViewEx?
Moderators Melba23 Posted August 30, 2018 Author Moderators Posted August 30, 2018 Tersion, I will release a new version once I am content that the changes I have mode to meet your requirements will not affect anything else in the UDF! Too often I have found that a tweak in one function can have very strange consequences elsewhere..... 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
robertocm Posted September 1, 2018 Posted September 1, 2018 Dear Melba23, I'm doing some tests wiht a gui that has an input box as the first control ($idFilt) i'm observing that Ctrl+arrow is 100% reliable for changing the selected cell in edit mode But Tab key gets out of the edit mode sometimes I think it could be related with this different 'patron' observed: With Ctrl+arrow: Right Arrow Arrow pressed Right Arrow released --> Input SetFocus --> Input KillFocus Right Arrow Arrow pressed Right Arrow released --> Input SetFocus --> Input KillFocus Right Arrow Arrow pressed Right Arrow released --> Input SetFocus --> Input KillFocus Right Arrow Arrow pressed Right Arrow released --> Input SetFocus --> Input KillFocus Right Arrow Arrow pressed Right Arrow released --> Input SetFocus --> Input KillFocus Whit Tab: --> Input SetFocus Tab Key pressed Tab Key released --> Input KillFocus --> Input SetFocus Tab Key pressed Tab Key released --> Input KillFocus --> Input SetFocus Tab Key pressed Tab Key released --> Input KillFocus --> Input SetFocus Tab Key pressed Tab Key released --> Input KillFocus --> Input SetFocus Tab Key pressed Tab Key released --> Input KillFocus Fragments of code to reproduce the test: ;GUISetState(@SW_SHOW) ;GaryFrost ;https://www.autoitscript.com/forum/index.php?s=&showtopic=48160&view=findpost&p=391271 ;Global Const $WM_COMMAND = 0x0111 ;Global Const $EN_CHANGE = 0x300 ;Global Const $EN_SETFOCUS = 0x100 ;Global Const $EN_KILLFOCUS = 0x200 GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") ... ;GaryFrost Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) ; high word Local $nID = BitAND($wParam, 0xFFFF) ; low word Local $hCtrl = $lParam Switch $nID Case $idFilt Switch $nNotifyCode Case $EN_SETFOCUS ConsoleWrite("--> Input SetFocus" & @CRLF) Case $EN_KILLFOCUS ConsoleWrite("--> Input KillFocus" & @CRLF & @CRLF) EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND i've made a temporal copy of the GUIListViewEx, and only for this test i've added #include <Misc.au3> and around line 4735 If _IsPressed("09") Then ConsoleWrite("Tab Key pressed" & @CRLF) ;Wait until key is released. While _IsPressed("09") Sleep(10) WEnd ConsoleWrite("Tab Key released" & @CRLF) EndIf And finally, similar for the left arrow key Many Thanks,
Moderators Melba23 Posted September 1, 2018 Author Moderators Posted September 1, 2018 robertocm, Quote around line 4735 Please be more specific about the location of your added code. There is already a check for key release in the code, so I am somewhat confused about exactly what you are looking to add. And I am also unsure as to the exact behaviour you are experiencing. Please can you provide a small working script that exhibits the same behaviour - rather than a couple of small fragments - otherwise I am feeling my way in the dark. 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
robertocm Posted September 2, 2018 Posted September 2, 2018 (edited) Dear Melba23, Below a working script that exhibits the same behaviour: - start editing with backspace in any row of the first visible column (F1) - press several times TAB and then ENTER - Change to other rows and repeat until TAB 'fails' (gets out of edit mode before ENTER) expandcollapse popup#include <GuiConstants.au3> #include <Excel.au3> #include <Date.au3> ;GUIListViewEx from Melba23 https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-27-may-16 #include "GUIListViewEx.au3" Opt( "MustDeclareVars", 1 ) ;https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-25-sep-17/?do=findComment&comment=1370017 ;Melba 23, Oct 2017 ;... and a right-click menu to select the colour of another column (1) of the selected row. Global $iYellow = "0xFFFF00", _ $iLtBlue = "0xCCCCFF", _ $iGreen = "0x00FF00", _ $iBlack = "0x000000", _ $iRed = "0xFF0000", _ $iBlue = "0x0000FF", _ $iWhite = "0xFFFFFF" Global $rstArray, $rstCount_1, $rstCount_2, $aColArBand[1][1], $tblname = "[CARGAS_REFINERIA]" Global $GuiWidth = @DesktopWidth-2, $GuiHight = @DesktopHeight-77 Global $hGui = GUICreate("Example", $GuiWidth, $GuiHight) GUISetBkColor(0xA9A9A9) GUISetFont(11, Default, Default, "Segoe UI") Global $idFilt = GUICtrlCreateInput("", 4, 1, 180, 33) GUICtrlSetBkColor(-1, 0xD3D3D3) Global $idDate = GUICtrlCreateDate("", 186, 1, 130, 33, $DTS_SHORTDATEFORMAT) Global $idDate2 = GUICtrlCreateDate("", 318, 1, 130, 33, $DTS_SHORTDATEFORMAT) Global $idCheckbox = GUICtrlCreateCheckbox("Some condition", 454, 1, 140, 33, $BS_AUTO3STATE) ;GUICtrlSetStyle(-1, $BS_AUTO3STATE ) GUICtrlSetFont(-1, 10) GUICtrlSetState(-1, 2) Local $cmdRefresh = GUICtrlCreateButton("", 602, 1, 60, 34, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 290, 0) Local $cInsSpec = GUICtrlCreateButton("Insert Row", 1087, 1, 92, 33, 0) GUICtrlSetFont(-1, 9) Local $cSpecChoose = GUICtrlCreateInput(1, 1181, 1, 50, 33) GUICtrlSetFont($cSpecChoose, 9) GUICtrlCreateUpdown($cSpecChoose, BitOr($UDS_WRAP, $UDS_ALIGNRIGHT)) GUICtrlSetLimit(-1, 9, 1) ;This is from Melba23 GUIListViewEx Global $cLV, $iLV, $vRet, $Row, $Col, $EditMode = 22 Local $iCheckState = True Local $iValue $cLV = GUICtrlCreateListView("F0|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10", 2, 35, $GuiWidth-4, $GuiHight-60) ;752 _GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;Set font GUICtrlSetFont($cLV, 13, Default, Default, "Segoe UI") ; Note edit control will use same font _GUICtrlListView_SetColumnWidth($cLV, 0, 27) _GUICtrlListView_SetColumnWidth($cLV, 1, 180) _GUICtrlListView_SetColumnWidth($cLV, 2, 140) _GUICtrlListView_SetColumnWidth($cLV, 3, 65) _GUICtrlListView_SetColumnWidth($cLV, 3, 65) _GUICtrlListView_SetColumnWidth($cLV, 4, 150) _GUICtrlListView_SetColumnWidth($cLV, 5, 70) _GUICtrlListView_SetColumnWidth($cLV, 6, 170) _GUICtrlListView_SetColumnWidth($cLV, 7, 180) _GUICtrlListView_SetColumnWidth($cLV, 8, 80) _GUICtrlListView_SetColumnWidth($cLV, 9, 80) ;Create context menu for native ListView Local $mContextmenu = GUICtrlCreateContextMenu($cLV) Local $mWhtFld = GUICtrlCreateMenuItem("White field", $mContextmenu) Local $mRedFld = GUICtrlCreateMenuItem("Red field", $mContextmenu) Local $mBluFld = GUICtrlCreateMenuItem("Blue field", $mContextmenu) Local $mGrnFld = GUICtrlCreateMenuItem("Green field", $mContextmenu) Local $mBlkFld = GUICtrlCreateMenuItem("Black field", $mContextmenu) GUICtrlCreateMenuItem("", $mContextmenu) Local $mDefFld = GUICtrlCreateMenuItem("Default field", $mContextmenu) ; Create array and fill listview Global $rstArray[10][11] For $i = 0 To 9 For $j = 1 To 9 $rstArray[$i][$j] = "SubItem " & $i & "-" & $j Next If Mod($i,2) = 0 Then $rstArray[$i][10] = True Else $rstArray[$i][10] = False EndIf Next ;Load the ListView with data _GUICtrlListView_AddArray($cLV, $rstArray) ;Melba23 ;Set array to give alternate line colouring $rstCount_1 = Ubound($rstArray) $rstCount_2 = Ubound($rstArray, 2) ReDim $aColArBand[$rstCount_1][$rstCount_2] For $i = 0 To $rstCount_1 - 1 If Mod($i,2) = 0 Then For $j = 0 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xFFFFFF" Next Else For $j = 0 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xE6E6E6" Next EndIf ;Check all items, see examples: ;https://www.autoitscript.com/wiki/Snippets_(_Checkboxes_) If $rstArray[$i][10] = True Then _GUICtrlListView_SetItemChecked($cLV, $i, True) EndIf Next ;Initiate LVEx - using filling array - user colours ;Note that using the left/right keys only returns a "selection change" message if the ListView has been set up to allow single cell highlighting $iLV = _GUIListViewEx_Init($cLV, $rstArray, 0, 0, False, 1 + 4 + 32 + 1024) ;Load the required ListView colour array _GUIListViewEx_LoadColour($iLV, $aColArBand) ;Set editable columns _GUIListViewEx_SetEditStatus($iLV, "1-10") ;Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV, "1", 2000) ;SPACEBAR (but then we have to prevent to change the checbox state) ;_GUIListViewEx_SetEditKey("20") ;If @error Then Exit MsgBox(0, "", @error) ;Register required message BEFORE any colour actions (register for sorting, dragging and editing) ;If colours used then this function must be run BEFORE GUISetState _GUIListViewEx_MsgRegister() ;Set deafult colours to use Global $aDefCols[4] = ["0x000000", "0xFEFEFE", "0xFFFFFF", "0x778899"] ;Sets default colours for user colour/single cell select enabled ListViews _GUIListViewEx_SetDefColours($iLV, $aDefCols) GUISetState(@SW_SHOW) GUICtrlSetState($cLV, $GUI_FOCUS) ControlSend($hGui, "", $cLV, "{DOWN}{RIGHT}{RIGHT}") ;_GUICtrlListView_ClickItem($cLV, 0, "left", True, 1) ;For testing ;GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $idFilt, $cmdRefresh OnFilt() Case $cInsSpec ;Insert spec row/col $iValue = GUICtrlRead($cSpecChoose) For $i = 1 To $iValue _GUIListViewEx_InsertSpec($iLV, -1, "") Next Case $mWhtFld To $mDefFld ;Check context menu items _SetColour($iMsg) EndSwitch $vRet = _GUIListViewEx_EventMonitor($EditMode) ;If @error Then ;MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) ;EndIf Switch @extended Case 1 ; This is returned after an edit attempt started by user action ;Restore checked state (because using spacebar for starting the edit mode has the 'disadvantage' of also changing the checked state) ;_GUICtrlListView_SetItemChecked($cLV, $Row, $iCheckState) _UpdateDatabase() Case 9 ; This is returned after a selection change by the user, then listview is active ;MsgBox($MB_SYSTEMMODAL, "Selection changed", "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) $Row = $vRet[1] $Col = $vRet[2] ;$iCheckState = _GUICtrlListView_GetItemChecked($cLV, $Row) Switch $Col Case 0 ;MsgBox(0, "", _GUICtrlListView_GetItemText($cLV, $Row, 0)) If $iCheckState = True Then ToolTip("Activate") Sleep(1000) ToolTip("") EndIf EndSwitch EndSwitch WEnd Func OnFilt() ;reload the ListView with new data, first clear the current content _GUICtrlListView_DeleteAllItems($cLV) ;close it within the UDF _GUIListViewEx_Close(0) ;reload the ListView with the new data _GUICtrlListView_AddArray($cLV, $rstArray) ;Initiate LVEx - using filling array - user colours $iLV = _GUIListViewEx_Init($cLV, $rstArray, 0, 0, False, 1 + 4 + 32 + 1024) ;Load the required ListView colour array Local $rst2Count_1 = UBound($rstArray) If $rst2Count_1 > $rstCount_1 Then Local $aTempColBand[$rst2Count_1][$rstCount_2] For $i = 0 To $rst2Count_1 - 1 If Mod($i,2) = 0 Then For $j = 0 To $rstCount_2 - 1 $aTempColBand[$i][$j] = ";0xFFFFFF" Next Else For $j = 0 To $rstCount_2 - 1 $aTempColBand[$i][$j] = ";0xE6E6E6" Next EndIf Next Else Local $aTempColBand = $aColArBand If $rst2Count_1 < $rstCount_1 Then ReDim $aTempColBand[$rst2Count_1][$rstCount_2] EndIf For $i = 0 To $rst2Count_1 - 1 If $rstArray[$i][10] = True Then _GUICtrlListView_SetItemChecked($cLV, $i, True) EndIf Next _GUIListViewEx_LoadColour($iLV, $aTempColBand) _GUIListViewEx_SetDefColours($iLV, $aDefCols) ;Set all columns editable _GUIListViewEx_SetEditStatus($iLV, "1-10") ;Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV, "1", 2000) ;_GUIListViewEx_BlockReDraw($iLV, False) ;WinSetState($hLV, "", @SW_UNLOCK) ;Melba23, GUIListViewEx ;WinSetState($hGLVEx_Editing, "", @SW_ENABLE) GUICtrlSetData($idFilt, "") ;GUICtrlSetState($idCheckbox, $GUI_UNCHECKED) EndFunc Func _UpdateDatabase() If $vRet = "" Then ;MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) EndIf EndFunc #cs ---------------------------------------------------------------------------- https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-25-sep-17/?do=findComment&comment=1370017 Melba 23, Oct 2017 But here is how you can use the UDF to have a column (2) which uses a combo to limit user edit options and a right-click menu to select the colour of another column (1) of the selected row. #ce ---------------------------------------------------------------------------- Func _SetColour($iCID) ; Get information on where last right click occurred within ListView Local $aContext = _GUIListViewEx_ContextPos() ; Set new colour required Local $sColSet = "", $aColArray, $aSplit, $fDef = False Switch $iCID Case $mWhtFld $sColSet = $iYellow & ";" & $iWhite ; Text colour followed by ";" Field colour preceded by ";" Case $mRedFld $sColSet = ";" & $iRed Case $mBluFld $sColSet = ";" & $iBlue Case $mGrnFld $sColSet = ";" & $iGreen Case $mBlkFld ;$sColSet = $iWhite & ";" ; Text colour followed by ";" $sColSet = $iWhite & ";" & $iBlack Case $mDefFld ;Get current colours $aColArray = _GUIListViewEx_ReturnArray($aContext[0], 2) $aSplit = StringSplit($aColArray[$aContext[1]][$aContext[2]], ";") ;Create required setting ;Text $sColSet = ";" & $aSplit[2] ; Set default flag $fDef = True ;Field $sColSet = $aSplit[1] & ";" $fDef = True EndSwitch If $sColSet Then ; Reset to default if needed If $fDef Then _GUIListViewEx_SetColour($aContext[0], ";", $aContext[1], 1) EndIf ; Set required item colour _GUIListViewEx_SetColour($aContext[0], $sColSet, $aContext[1], 1) EndIf EndFunc ;GaryFrost ;https://www.autoitscript.com/forum/index.php?s=&showtopic=48160&view=findpost&p=391271 Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) ; high word Local $nID = BitAND($wParam, 0xFFFF) ; low word Local $hCtrl = $lParam Switch $nID Case $idFilt Switch $nNotifyCode Case $EN_SETFOCUS Beep(100, 100) Sleep(2000) ConsoleWrite("--> Input SetFocus" & @CRLF) Case $EN_KILLFOCUS ConsoleWrite("--> Input KillFocus" & @CRLF & @CRLF) EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND For the tests uncomment the line: GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") It stopts tab for 2 seconds Many Thanks, Edited September 2, 2018 by robertocm
robertocm Posted September 2, 2018 Posted September 2, 2018 Dear Melba23, This is about _GUIListViewEx_ChangeItem It seems that using this function makes the UDF to lose the row component of selection To test: in the example below edit any cell, after editing press down arrow: see the dotted line in first row Many Thanks expandcollapse popup#cs ---------------------------------------------------------------------------- Melba23 https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-22-feb-18/?do=findComment&comment=1397949 #ce ---------------------------------------------------------------------------- #include <GuiConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GUIListViewEx.au3" ;Create GUI Global $GuiWidth = @DesktopWidth-2, $GuiHight = @DesktopHeight-77 ;Create GUI Global $hGui = GUICreate("LVEx Change Item", $GuiWidth, $GuiHight) Global $idFilt = GUICtrlCreateInput("", 4, 1, 180, 33) GUICtrlSetBkColor(-1, 0xD3D3D3) ;$cEdit_Button = GUICtrlCreateButton("Edit Selected", 430, 390, 200, 110) Global $cLV, $iLV, $Row, $Col, $EditMode = 22 Local $vRet ;Create array and fill listview Local $aLV_List[10][10] For $i = 0 To 9 For $j = 0 To 9 $aLV_List[$i][$j] = "SubItem " & $i & "-" & $j Next Next $cLV = GUICtrlCreateListView("F0|F1|F2|F3|F4|F5|F6|F7|F8|F9", 2, 35, $GuiWidth-4, $GuiHight-60) ;752 _GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_SetColumnWidth($cLV, 0, 150) _GUICtrlListView_SetColumnWidth($cLV, 1, 150) _GUICtrlListView_SetColumnWidth($cLV, 2, 150) _GUICtrlListView_SetColumnWidth($cLV, 3, 150) _GUICtrlListView_SetColumnWidth($cLV, 4, 150) _GUICtrlListView_SetColumnWidth($cLV, 5, 150) _GUICtrlListView_SetColumnWidth($cLV, 6, 150) _GUICtrlListView_SetColumnWidth($cLV, 7, 150) _GUICtrlListView_SetColumnWidth($cLV, 8, 150) _GUICtrlListView_SetColumnWidth($cLV, 9, 150) _GUICtrlListView_SetColumnWidth($cLV, 10, 150) ;Load the ListView with data _GUICtrlListView_AddArray($cLV, $aLV_List) ;Melba23 ;Set array to give alternate line colouring $rstCount_1 = Ubound($aLV_List) $rstCount_2 = Ubound($aLV_List, 2) Local $aColArBand[$rstCount_1][$rstCount_2] For $i = 0 To $rstCount_1 - 1 If Mod($i,2) = 0 Then For $j = 0 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xFFFFFF" Next Else For $j = 0 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xE6E6E6" Next EndIf ;Check all items, see examples: ;https://www.autoitscript.com/wiki/Snippets_(_Checkboxes_) _GUICtrlListView_SetItemChecked($cLV, $i, True) Next ;Initiate LVEx - using filling array - user colours ;Note that using the left/right keys only returns a "selection change" message if the ListView has been set up to allow single cell highlighting $iLV = _GUIListViewEx_Init($cLV, $aLV_List, 0, 0, False, 1 + 4 + 32 + 1024) ;Load the required ListView colour array _GUIListViewEx_LoadColour($iLV, $aColArBand) ;Set editable columns _GUIListViewEx_SetEditStatus($iLV, "*") ;Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV, "1", 2000) ;SPACEBAR (but then we have to prevent to change the checbox state) ;_GUIListViewEx_SetEditKey("20") ;If @error Then Exit MsgBox(0, "", @error) ;Register required message BEFORE any colour actions (register for sorting, dragging and editing) ;If colours used then this function must be run BEFORE GUISetState _GUIListViewEx_MsgRegister() ;Set deafult colours to use Global $aDefCols[4] = ["0x000000", "0xFEFEFE", "0xFFFFFF", "0x778899"] ;Sets default colours for user colour/single cell select enabled ListViews _GUIListViewEx_SetDefColours($iLV, $aDefCols) ;_GUIListViewEx_BlockReDraw($iLV, False) GUISetState(@SW_SHOW) GUICtrlSetState($cLV, $GUI_FOCUS) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ;Case $cEdit_Button ;_Edit_from_Button() EndSwitch $vRet = _GUIListViewEx_EventMonitor($EditMode) If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 1 ; This is returned after an edit attempt _UpdateDatabase() Case 9 ; This is returned after a selection change ;MsgBox($MB_SYSTEMMODAL, "Selection changed", "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) $Row = $vRet[1] $Col = $vRet[2] EndSwitch WEnd Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $vRet = _GUIListViewEx_EventMonitor($EditMode) ;If @error Then ;MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) ;EndIf Switch @extended Case 1 ; This is returned after an edit attempt started by user action _UpdateDatabase() Case 9 ; This is returned after a selection change by the user, then listview is active ;MsgBox($MB_SYSTEMMODAL, "Selection changed", "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) $Row = $vRet[1] $Col = $vRet[2] EndSwitch WEnd Func _UpdateDatabase() If $vRet = "" Then ;MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else ;_ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) For $i = 1 To $vRet[0][0] If $vRet[$i][1] < 9 Then _GUIListViewEx_ChangeItem($iLV, $vRet[$i][0], $vRet[$i][1] + 1, "ChangedItem") EndIf Next EndIf EndFunc
Moderators Melba23 Posted September 2, 2018 Author Moderators Posted September 2, 2018 (edited) robertocm, I see the problem - working on it. M23 Edit: Found and fixed (I hope). Now looking at the earlier problem. Edited September 2, 2018 by Melba23 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
Moderators Melba23 Posted September 3, 2018 Author Moderators Posted September 3, 2018 robertocm, I can reproduce the problem of the {TAB} key exiting the edit process, but I cannot find a way of preventing it. As I mentioned above there is already a check for the user releasing whatever key was used and in my extensive checks the {TAB} key was successfully released every time. What I think is happening is that Windows is intercepting a subsequent {TAB} key and, when there are other controls in the GUI, treating it as a TABSTOP command rather then allowing the UDF to treat it as a user input as the UDF has not yet returned to the section of its code where it waits for user input. The fact that the problem appears to be more prevalent when the {TAB} key is pressed in quick succession to advance the edit location without actually editing the cells makes this more likely to be the correct diagnosis in my opinion - using it to advance after each cell has been edited does not seem to produce the same problem. So not a lot I can do about it, sorry. 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
Moderators Melba23 Posted September 3, 2018 Author Moderators Posted September 3, 2018 (edited) robertocm & Tersion, Here is the latest Beta code incorporating all of the small tweaks that I have introduced following yoru interventions over the past few pages of this thread: Please try (and hopefully fail) to break it again! M23 Edited October 3, 2018 by Melba23 Beta code removed 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
robertocm Posted September 3, 2018 Posted September 3, 2018 (edited) Dear Melba23, Regarding {TAB} issue, an only as an idea, i would suggest to replace for the arrows keys: without Ctrl During editing, checking the position of cursor: - If the cursor is at the right end of the text, pressing right key confirms and select next cell - If cursor is at the begining, pressing left key confirms and select previous cell - Up and Down always confirming and changing selection Just an idea Many Thanks! Note: i'm seeing this in Ms Access tables Edited September 3, 2018 by robertocm
Moderators Melba23 Posted September 3, 2018 Author Moderators Posted September 3, 2018 robertocm, Thanks for the suggestion, but I seem to remember long ago when I first coded this UDF that it worked that way - but then people complained that moving around in the edit control sometimes fires the "end of edit" event, so I changed that event to "Ctrl-arrow". And I am not changing back! 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
robertocm Posted September 3, 2018 Posted September 3, 2018 Dear Melba23, ok, was only an idea Many Thanks
robertocm Posted September 30, 2018 Posted September 30, 2018 Dear Melba23, In the example below there is a main gui with a listview and a child GUI with a second listview. - Edit some cell in column 1 for displaying child gui (first visible column, because column 0 is partially hidden) - If i press down arrow key until first row of second listview becomes selected: it seems that _GUIListViewEx_EventMonitor does not return the correct row index (Case 9) - If i do the same by clicking the returned row is ok Many Thanks!! expandcollapse popup#include <GuiConstants.au3> ;GUIListViewEx from Melba23 https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-27-may-16 #include "GUIListViewEx.au3" Opt("MustDeclareVars", 1) ;https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-25-sep-17/?do=findComment&comment=1370017 ;Melba 23, Oct 2017 ;... and a right-click menu to select the colour of another column (1) of the selected row. Global $iDarkSlateGray = "0x2F4F4F", _ $iLtBlue = "0xCCCCFF", _ $iGreen = "0x00FF00", _ $iBlack = "0x000000", _ $iWheat = "0xF5DEB3", _ $iBlue = "0x0000FF", _ $iLightBlue = "0xADD8E6" ;_ErrADODB From spudw2k ;https://www.autoitscript.com/forum/topic/105875-adodb-example/ Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB") Local $sSQL = '', $FromB, $aColArBand[0][0], $rstCount_1 = 0, $rstCount_2 = 15, $rstArray[0][$rstCount_2] Local $GuiWidth = @DesktopWidth-2, $GuiHight = @DesktopHeight-77 Local $hMainGUI = GUICreate("EXAMPLE: Edit first column to show child", $GuiWidth, $GuiHight) GUISetBkColor(0xA9A9A9) GUISetFont(11, Default, Default, "Segoe UI") GUICtrlCreateLabel("Edit: [DOUBLE CLICK] or [SPACE BAR]. Editing: [ENTER] confirms, [ESC] cancels. Editing, change cell: [TAB] or [CTRL + ARROW]", 4, $GuiHight-32, $GuiWidth-10, 31, BitOR($SS_SIMPLE, $SS_SUNKEN)) ;GUICtrlSetFont(-1, 11), Default, Default, "Segoe UI") Global $idFilt = GUICtrlCreateInput("", 4, 1, 180, 33) GUICtrlSetBkColor(-1, 0xD3D3D3) ;GUICtrlSetFont(-1, 11) Global $idDate = GUICtrlCreateDate("", 186, 1, 130, 33, $DTS_SHORTDATEFORMAT) Global $idDate2 = GUICtrlCreateDate("", 318, 1, 130, 33, $DTS_SHORTDATEFORMAT) Global $idCheckbox = GUICtrlCreateCheckbox("Some", 454, 1, 80, 33, $BS_AUTO3STATE) ;GUICtrlSetStyle(-1, $BS_AUTO3STATE ) GUICtrlSetFont(-1, 10) GUICtrlSetState(-1, 2) Local $cmdRefresh = GUICtrlCreateButton("", 536, 1, 60, 34, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 290, 0) Local $cmdOpt1 = GUICtrlCreateButton("Option 1", 888, 1, 92, 33) GUICtrlSetFont(-1, 9) GUICtrlSetBkColor(-1, 0xADD8E6) Local $cmdOpt2 = GUICtrlCreateButton("Option 2", 984, 1, 92, 33) GUICtrlSetFont(-1, 9) GUICtrlSetBkColor(-1, $iWheat) Local $cInsSpec = GUICtrlCreateButton("Insert Fila", 1087, 1, 92, 33, 0) GUICtrlSetFont(-1, 9) Local $cSpecChoose = GUICtrlCreateInput(1, 1181, 1, 50, 33) GUICtrlSetFont($cSpecChoose, 9) GUICtrlCreateUpdown($cSpecChoose, BitOr($UDS_WRAP, $UDS_ALIGNRIGHT)) GUICtrlSetLimit(-1, 9, 1) ;This is from Melba23 GUIListViewEx Global $aLV, $cLV, $iLV, $vRet, $Row, $Col, $EditMode = 22 Local $iCheckState = True Local $iValue $cLV = GUICtrlCreateListView("C0|C1|C2|C3|C4|C5|C6|C7|C8|C9|C10|C11|C12|C13|C14", 2, 35, $GuiWidth-4, $GuiHight-62) _GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;Melba23, ex_alternate_row_colors ;_GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;Set font GUICtrlSetFont($cLV, 13, Default, Default, "Segoe UI") ; Note edit control will use same font _GUICtrlListView_SetColumnWidth($cLV, 0, 25) _GUICtrlListView_SetColumnWidth($cLV, 1, 300) _GUICtrlListView_SetColumnWidth($cLV, 2, 200) _GUICtrlListView_SetColumnWidth($cLV, 3, 120) _GUICtrlListView_SetColumnWidth($cLV, 4, 60) _GUICtrlListView_SetColumnWidth($cLV, 5, 185) _GUICtrlListView_SetColumnWidth($cLV, 6, 90) _GUICtrlListView_SetColumnWidth($cLV, 7, 90) _GUICtrlListView_SetColumnWidth($cLV, 8, 90) _GUICtrlListView_SetColumnWidth($cLV, 9, 130) _GUICtrlListView_SetColumnWidth($cLV, 10, 90) _GUICtrlListView_SetColumnWidth($cLV, 11, 100) _GUICtrlListView_SetColumnWidth($cLV, 12, 0) _GUICtrlListView_SetColumnWidth($cLV, 13, 0) _GUICtrlListView_SetColumnWidth($cLV, 14, 0) ;Create context menu for native ListView Local $mContextmenu = GUICtrlCreateContextMenu($cLV) Local $mWhtFld = GUICtrlCreateMenuItem("Option 1", $mContextmenu) Local $mRedFld = GUICtrlCreateMenuItem("Option 2", $mContextmenu) ;Local $mBluFld = GUICtrlCreateMenuItem("Blue field", $mContextmenu) ;Local $mGrnFld = GUICtrlCreateMenuItem("Green field", $mContextmenu) ;Local $mBlkFld = GUICtrlCreateMenuItem("Black field", $mContextmenu) GUICtrlCreateMenuItem("", $mContextmenu) Local $mDefFld = GUICtrlCreateMenuItem("Reset", $mContextmenu) ;Create array and fill listview Local $rstArray[10][15] For $i = 0 To 9 $rstArray[$i][0] = "Item " & $i For $j = 1 To 11 $rstArray[$i][$j] = "SubItem " & $i & "-" & $j Next If Mod($i,2) = 0 Then $rstArray[$i][12] = True $rstArray[$i][12] = False $rstArray[$i][12] = True Else $rstArray[$i][12] = False $rstArray[$i][12] = True $rstArray[$i][12] = False EndIf Next ;Load the ListView with data _GUICtrlListView_AddArray($cLV, $rstArray) Colors_and_Checks() ;Initiate LVEx - using filling array - user colours ;Note that using the left/right keys only returns a "selection change" message if the ListView has been set up to allow single cell highlighting $iLV = _GUIListViewEx_Init($cLV, $rstArray, 0, 0, False, 1 + 4 + 32 + 1024) ;Prevents ListView redrawing during looped Insert/Delete/Change calls ;_GUIListViewEx_BlockReDraw($iLV, True) ;Load the required ListView colour array _GUIListViewEx_LoadColour($iLV, $aColArBand) ;Read the current ListView content ;$aLV = _GUIListViewEx_ReturnArray($iLV, 3) ;_ArrayDisplay($aLV, "current content", Default, 8) ;$aLV = $rstArray ;Comprobando que coinciden ;_ArrayDisplay($rstArray, "recordset content", Default, 8) ;Set editable columns _GUIListViewEx_SetEditStatus($iLV, "1;3-11") ; Default = standard text edit _GUIListViewEx_SetEditStatus($iLV, 2, 2, "Value 1|Value 2|Value 3", True) ; 2 = Read-only combo ;Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV, "1", 2000) ;SPACEBAR (but then we have to prevent to change the checbox state) _GUIListViewEx_SetEditKey("20") ;If @error Then Exit MsgBox(0, "", @error) ;Mais rápido ;$aGLVEx_Data[0][23] = "20" ;Register required message BEFORE any colour actions (register for sorting, dragging and editing) ;If colours used then this function must be run BEFORE GUISetState _GUIListViewEx_MsgRegister() ;Set default colours to use Global $aDefCols[4] = ["0x000000", "0xFEFEFE", "0xFFFFFF", "0x778899"] ;Sets default colours for user colour/single cell select enabled ListViews _GUIListViewEx_SetDefColours($iLV, $aDefCols) ;_GUIListViewEx_BlockReDraw($iLV, False) Local $hGUI2 = GUICreate("Clients", 700, 500) Local $cmdCliSel = GUICtrlCreateButton("Confirm", 10, 1, 100, 33) Local $cmdCliCancel = GUICtrlCreateButton("Cancel", 114, 1, 100, 33) GUICtrlSetFont(-1, 9) Local $cLV_2 = GUICtrlCreateListView("Name|Code", 2, 35, 700-4, 500-40, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS) ) _GUICtrlListView_SetExtendedListViewStyle($cLV_2, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 600) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 92) Local $iLV_2 = _GUIListViewEx_Init($cLV_2) ;help: when a new window is created it becomes the "default" window for future GUI operations (including control creation). ;In our case we want to work with the main window, not the test window, so we "switch". ;GUISwitch($hMainGUI) ;Some GUI functions allow you to use the window handle in the function call itself - these functions will do the switch automatically. In our example we could have done this with: GUISetState(@SW_SHOW, $hMainGUI) GUICtrlSetState($cLV, $GUI_FOCUS) ;ControlFocus($hMainGUI, "", $cLV) ;ConsoleWrite(ControlGetFocus($hMainGUI)) ;Give keyboard focus ;Global $hLV = GUICtrlGetHandle($cLV) ;_WinAPI_SetFocus($hLV) ;WinSetState($hLV, "", @SW_DISABLE) ;ControlSend($hMainGUI, "", $cLV, "{DOWN}{RIGHT}{RIGHT}") ;_GUICtrlListView_ClickItem($cLV, 0, "left", True, 1) ;help file ;_GUICtrlListView_SetItemState($cLV, 0, $LVIS_FOCUSED, $LVIS_FOCUSED) ;_GUICtrlListView_SetItemFocused($cLV, 1) ;_GUICtrlListView_SetItemSelected($cLV, 2, True, True ) ;Help: GUI Reference; Advanced GUIGetMsg and Multiple Windows ;When called with the 1 parameter instead of returning an event value an array will be returned, ;array contains the event (in $aArray[0]) and extra information such as the window handle (in $aArray[1]) ;Initialize a Local variable. Local $aMsg = 0 While 1 ;Assign to $aMsg the advanced GUI messages. $aMsg = GUIGetMsg(1) ;Switch from GUIs Switch $aMsg[1] Case $hMainGUI ;The event comes from the $hMainGUI ;Switch from event ID Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $idFilt, $cmdRefresh OnFilt() Case $cInsSpec ;Insert spec row/col $iValue = GUICtrlRead($cSpecChoose) For $i = 1 To $iValue _GUIListViewEx_InsertSpec($iLV, -1, "") Next Case $cmdOpt1 $FromB = True _SetColour($mWhtFld) Case $cmdOpt2 $FromB = True _SetColour($mRedFld) Case $mWhtFld To $mDefFld ;Check context menu items _SetColour($iMsg) EndSwitch Case $hGUI2 ;The event comes from the $hGUI2 ;Switch from event ID Switch $aMsg[0] Case $GUI_EVENT_CLOSE ;GUIDelete($hGUI2) GUISetState(@SW_HIDE, $hGUI2) Case $cmdCliSel Local $Name = _GUICtrlListView_GetItemText($cLV_2, $Row_2, 0) Local $Code = _GUICtrlListView_GetItemText($cLV_2, $Row_2, 1) ConsoleWrite($Row_2 & $Name & @TAB & $Code) GUISetState(@SW_HIDE, $hGUI2) ;Prevents ListView redrawing during looped Insert/Delete/Change calls _GUIListViewEx_BlockReDraw($iLV, True) _GUIListViewEx_ChangeItem($iLV, $Row, 1, $Name) _GUIListViewEx_ChangeItem($iLV, $Row, 7, $Code) _GUIListViewEx_BlockReDraw($iLV, False) Case $cmdCliCancel GUISetState(@SW_HIDE, $hGUI2) EndSwitch EndSwitch $vRet = _GUIListViewEx_EventMonitor($EditMode) ;If @error Then ;MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) ;EndIf Switch @extended Case 1 ; This is returned after an edit attempt started by user action ;Restore checked state (because using spacebar for starting the edit mode has the 'disadvantage' of also changing the checked state) _GUICtrlListView_SetItemChecked($cLV, $Row, $iCheckState) _UpdateDatabase() Case 9 ; This is returned after a selection change by the user, then listview is active If $vRet[0] = 1 Then MsgBox($MB_SYSTEMMODAL, "LV: " & $vRet[0], "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) $Row = $vRet[1] $Col = $vRet[2] $iCheckState = _GUICtrlListView_GetItemChecked($cLV, $Row) Else MsgBox($MB_SYSTEMMODAL, "LV: " & $vRet[0], "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) Local $Row_2 = $vRet[1] Local $Col_2 = $vRet[2] EndIf Switch $Col Case 0 ;MsgBox(0, "", _GUICtrlListView_GetItemText($cLV, $Row, 0)) If $iCheckState = True Then ToolTip("Option 1") Sleep(1000) ToolTip("") Else ToolTip("Option 2") Sleep(1000) ToolTip("") EndIf EndSwitch EndSwitch WEnd Func OnFilt() ;WinSetState($hLV, "", @SW_LOCK) ;_GUIListViewEx_BlockReDraw($iLV, True) ;reload the ListView with new data, first clear the current content _GUICtrlListView_DeleteAllItems($cLV) ;close it within the UDF _GUIListViewEx_Close(1) ;reload the ListView with the new data _GUICtrlListView_AddArray($cLV, $rstArray) Colors_and_Checks() ;Initiate LVEx - using filling array - user colours $iLV = _GUIListViewEx_Init($cLV, $rstArray, 0, 0, False, 1 + 4 + 32 + 1024) ;_GUIListViewEx_BlockReDraw($iLV, True) ;Load the required ListView colour array _GUIListViewEx_LoadColour($iLV, $aColArBand) _GUIListViewEx_SetDefColours($iLV, $aDefCols) ;Read the current ListView content ;$aLV = _GUIListViewEx_ReturnArray($iLV, 3) ;$aLV = $rstArray ;_ArrayDisplay($aLV, "current content", Default, 8) ;Set editable columns _GUIListViewEx_SetEditStatus($iLV, "1;3-11") ; Default = standard text edit _GUIListViewEx_SetEditStatus($iLV, 2, 2, "Value 1|Value 2|Value 3", True) ; 2 = Read-only combo ;Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV, "1", 2000) ;_GUIListViewEx_BlockReDraw($iLV, False) ;WinSetState($hLV, "", @SW_UNLOCK) ;Melba23, GUIListViewEx ;WinSetState($hGLVEx_Editing, "", @SW_ENABLE) EndFunc Func Colors_and_Checks() ;Melba23 ;Set array to give alternate line colouring $rstCount_1 = Ubound($rstArray) ReDim $aColArBand[$rstCount_1][$rstCount_2] For $i = 0 To $rstCount_1 - 1 If Mod($i,2) = 0 Then ;$aColArBand[$i][0] = ";0xFFFFFF" ;Option 1, Option 2 If $rstArray[$i][12] = True Then $aColArBand[$i][1] = ";" & $iLightBlue ElseIf $rstArray[$i][13] = True Then $aColArBand[$i][1] = ";" & $iWheat Else $aColArBand[$i][1] = ";0xFFFFFF" EndIf For $j = 2 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xFFFFFF" Next Else ;$aColArBand[$i][0] = ";0xE6E6E6" If $rstArray[$i][12] = True Then $aColArBand[$i][1] = ";" & $iLightBlue ElseIf $rstArray[$i][13] = True Then $aColArBand[$i][1] = ";" & $iWheat Else $aColArBand[$i][1] = ";0xE6E6E6" EndIf For $j = 2 To $rstCount_2 - 1 $aColArBand[$i][$j] = ";0xE6E6E6" Next EndIf ;Check items, see examples: https://www.autoitscript.com/wiki/Snippets_(_Checkboxes_) If $rstArray[$i][14] = True Then _GUICtrlListView_SetItemChecked($cLV, $i, True) EndIf Next EndFunc Func _UpdateDatabase() If $vRet = "" Then ;MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else ;_ArrayDisplay($aLV, "ListView " & _GUIListViewEx_GetActive() & " Listview content", Default, 8) ;_ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) ;MsgBox($MB_SYSTEMMODAL, "", $vRet[1][3]) ;MsgBox($MB_SYSTEMMODAL, "", _GUIListViewEx_GetLastSelItem()) ;ListViewIndex|Row|Col ;Ter en conta o diseño das matrices: ;_GUIListViewEx_EventMonitor: Total number of edits in [0][0] element --> primeiro valor en F1C0 ;_GUIListViewEx_ReturnArray ...For mode 2/3: Always 0-based 2D array --> primeiro valor en F0C0 For $i = 1 To $vRet[0][0] If $vRet[$i][1] = 1 Then ;Create array and fill listview Local $rstArray_2[10][2] For $i = 0 To 9 $rstArray_2[$i][0] = "Name " & $i $rstArray_2[$i][1] = "Cod-" & $i Next _GUICtrlListView_DeleteAllItems($cLV_2) ;close it within the UDF _GUIListViewEx_Close(2) ;reload the ListView with the new data _GUICtrlListView_AddArray($cLV_2, $rstArray_2) $iLV_2 = _GUIListViewEx_Init($cLV_2) ;Local $arrr[2][2] = [[1, "A"], [2, "B"]] ;_GUIListViewEx_Insert ($arrr) GUISetState (@SW_SHOW, $hGUI2) _GUIListViewEx_SetActive($iLV_2) EndIf Next EndIf EndFunc #cs ---------------------------------------------------------------------------- https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-25-sep-17/?do=findComment&comment=1370017 Melba 23, Oct 2017 But here is how you can use the UDF to have a column (2) which uses a combo to limit user edit options and a right-click menu to select the colour of another column (1) of the selected row. #ce ---------------------------------------------------------------------------- Func _SetColour($iCID) If $FromB = False Then ;Get information on where last right click occurred within ListView Local $aContext = _GUIListViewEx_ContextPos() Else Local $aContext[3] =[1, $Row, $Col] $FromB = False EndIf ;Set new colour required Local $sColSet = "", $aColArray, $aSplit, $fDef = False Switch $iCID Case $mWhtFld ;$sColSet = $iDarkSlateGray & ";" & $iLightBlue ; Text colour followed by ";" Field colour preceded by ";" $sColSet = ";" & $iLightBlue ; Text colour followed by ";" Field colour preceded by ";" Case $mRedFld $sColSet = ";" & $iWheat _GUICtrlListView_SetItemChecked($cLV, $aContext[1], False) ;Case $mBluFld ;$sColSet = ";" & $iBlue ;Case $mGrnFld ;$sColSet = ";" & $iGreen ;Case $mBlkFld ;$sColSet = $iWhite & ";" ; Text colour followed by ";" ;$sColSet = $iWhite & ";" & $iBlack Case $mDefFld ;Get current colours ;$aColArray = _GUIListViewEx_ReturnArray($aContext[0], 2) ;_ArrayDisplay($aColArray, "colors", Default, 8) ;Reset to default if needed If Mod($aContext[1],2) > 0 Then $sColSet = ";0xE6E6E6" Else $sColSet = "" EndIf _GUICtrlListView_SetItemChecked($cLV, $aContext[1], True) EndSwitch ;Set required item colour _GUIListViewEx_SetColour($aContext[0], $sColSet, $aContext[1], 1) ;For $i = 1 To 2 ; For each column... ;_GUIListViewEx_SetColour($aContext[0], $sColSet, $aContext[1], $i) ;Next EndFunc
Moderators Melba23 Posted September 30, 2018 Author Moderators Posted September 30, 2018 (edited) bertocm, If you post some runnable code I will take a look - at the moment I get this in the SciTE console: Quote "M:\Program\Au3 Scripts\fred4.au3"(227,32) : warning: $iMsg: possibly used before declaration. _SetColour($iMsg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "M:\Program\Au3 Scripts\fred4.au3"(238,73) : warning: $Row_2: possibly used before declaration. Local $Name = _GUICtrlListView_GetItemText($cLV_2, $Row_2, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "M:\Program\Au3 Scripts\fred4.au3"(227,32) : error: $iMsg: undeclared global variable. _SetColour($iMsg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ M23 P.S. And even better: strip out all of the colour and other unnecessary stuff so that the code is a small as possible - that will save me from having to do it so that I do not have to wade through a bunch of irrelevant code. Edited September 30, 2018 by Melba23 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
robertocm Posted September 30, 2018 Posted September 30, 2018 (edited) Dear Melba23, sorry, here a simplyfied and revised (Scite SyntaxCheck) version Many Thank! expandcollapse popup#include <GuiConstants.au3> ;GUIListViewEx from Melba23 https://www.autoitscript.com/forum/topic/182492-guilistviewex-new-version-27-may-16 #include "GUIListViewEx.au3" Opt("MustDeclareVars", 1) Local $rstCount_1 = 0, $rstCount_2 = 15, $rstArray[0][$rstCount_2] Local $GuiWidth = @DesktopWidth-2, $GuiHight = @DesktopHeight-77 Local $aLV, $cLV, $iLV, $vRet, $Row, $Col, $EditMode = 22 Local $Name, $Code, $Row_2 Local $hMainGUI = GUICreate("EXAMPLE: Edit first column to show child", $GuiWidth, $GuiHight) GUISetBkColor(0xA9A9A9) GUISetFont(11, Default, Default, "Segoe UI") $cLV = GUICtrlCreateListView("C0|C1|C2|C3|C4|C5|C6|C7|C8|C9|C10|C11|C12|C13|C14", 2, 35, $GuiWidth-4, $GuiHight-62) _GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;Melba23, ex_alternate_row_colors ;_GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ;Set font GUICtrlSetFont($cLV, 13, Default, Default, "Segoe UI") ; Note edit control will use same font _GUICtrlListView_SetColumnWidth($cLV, 0, 25) _GUICtrlListView_SetColumnWidth($cLV, 1, 300) _GUICtrlListView_SetColumnWidth($cLV, 2, 200) _GUICtrlListView_SetColumnWidth($cLV, 3, 120) _GUICtrlListView_SetColumnWidth($cLV, 4, 60) _GUICtrlListView_SetColumnWidth($cLV, 5, 185) _GUICtrlListView_SetColumnWidth($cLV, 6, 90) _GUICtrlListView_SetColumnWidth($cLV, 7, 90) _GUICtrlListView_SetColumnWidth($cLV, 8, 90) _GUICtrlListView_SetColumnWidth($cLV, 9, 130) _GUICtrlListView_SetColumnWidth($cLV, 10, 90) _GUICtrlListView_SetColumnWidth($cLV, 11, 100) _GUICtrlListView_SetColumnWidth($cLV, 12, 0) _GUICtrlListView_SetColumnWidth($cLV, 13, 0) _GUICtrlListView_SetColumnWidth($cLV, 14, 0) ;Create array and fill listview Local $rstArray[10][15] For $i = 0 To 9 $rstArray[$i][0] = "Item " & $i For $j = 1 To 11 $rstArray[$i][$j] = "SubItem " & $i & "-" & $j Next If Mod($i,2) = 0 Then $rstArray[$i][12] = True $rstArray[$i][12] = False $rstArray[$i][12] = True Else $rstArray[$i][12] = False $rstArray[$i][12] = True $rstArray[$i][12] = False EndIf Next ;Load the ListView with data _GUICtrlListView_AddArray($cLV, $rstArray) ;Initiate LVEx - using filling array - user colours ;Note that using the left/right keys only returns a "selection change" message if the ListView has been set up to allow single cell highlighting $iLV = _GUIListViewEx_Init($cLV, $rstArray, 0, 0, False, 1 + 4 + 32 + 1024) ;Set editable columns _GUIListViewEx_SetEditStatus($iLV, "1;3-11") ; Default = standard text edit _GUIListViewEx_SetEditStatus($iLV, 2, 2, "Value 1|Value 2|Value 3", True) ; 2 = Read-only combo _GUIListViewEx_MsgRegister() Local $hGUI2 = GUICreate("Clients", 700, 500) Local $cmdCliSel = GUICtrlCreateButton("Confirm", 10, 1, 100, 33) Local $cmdCliCancel = GUICtrlCreateButton("Cancel", 114, 1, 100, 33) GUICtrlSetFont(-1, 9) Local $cLV_2 = GUICtrlCreateListView("Name|Code", 2, 35, 700-4, 500-40, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS) ) _GUICtrlListView_SetExtendedListViewStyle($cLV_2, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 600) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 92) Local $iLV_2 = _GUIListViewEx_Init($cLV_2) GUISetState(@SW_SHOW, $hMainGUI) GUICtrlSetState($cLV, $GUI_FOCUS) Local $aMsg = 0 While 1 ;Assign to $aMsg the advanced GUI messages. $aMsg = GUIGetMsg(1) ;Switch from GUIs Switch $aMsg[1] Case $hMainGUI ;The event comes from the $hMainGUI ;Switch from event ID Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit EndSwitch Case $hGUI2 ;The event comes from the $hGUI2 ;Switch from event ID Switch $aMsg[0] Case $GUI_EVENT_CLOSE ;GUIDelete($hGUI2) GUISetState(@SW_HIDE, $hGUI2) Case $cmdCliSel Local $Name = _GUICtrlListView_GetItemText($cLV_2, $Row_2, 0) Local $Code = _GUICtrlListView_GetItemText($cLV_2, $Row_2, 1) GUISetState(@SW_HIDE, $hGUI2) Case $cmdCliCancel GUISetState(@SW_HIDE, $hGUI2) EndSwitch EndSwitch $vRet = _GUIListViewEx_EventMonitor($EditMode) ;If @error Then ;MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) ;EndIf Switch @extended Case 1 ; This is returned after an edit attempt started by user action _UpdateDatabase() Case 9 ; This is returned after a selection change by the user, then listview is active If $vRet[0] = 1 Then MsgBox($MB_SYSTEMMODAL, "LV: " & $vRet[0], "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) $Row = $vRet[1] $Col = $vRet[2] Else MsgBox($MB_SYSTEMMODAL, "LV: " & $vRet[0], "New selection:" & @CRLF & "Row: " & $vRet[1] & @CRLF & "Col: " & $vRet[2]) Local $Row_2 = $vRet[1] Local $Col_2 = $vRet[2] EndIf EndSwitch WEnd Func _UpdateDatabase() If $vRet = "" Then ;MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else ;_ArrayDisplay($aLV, "ListView " & _GUIListViewEx_GetActive() & " Listview content", Default, 8) ;_ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) ;MsgBox($MB_SYSTEMMODAL, "", $vRet[1][3]) ;MsgBox($MB_SYSTEMMODAL, "", _GUIListViewEx_GetLastSelItem()) ;ListViewIndex|Row|Col ;Ter en conta o diseño das matrices: ;_GUIListViewEx_EventMonitor: Total number of edits in [0][0] element --> primeiro valor en F1C0 ;_GUIListViewEx_ReturnArray ...For mode 2/3: Always 0-based 2D array --> primeiro valor en F0C0 For $i = 1 To $vRet[0][0] If $vRet[$i][1] = 1 Then ;Create array and fill listview Local $rstArray_2[10][2] For $i = 0 To 9 $rstArray_2[$i][0] = "Name " & $i $rstArray_2[$i][1] = "Cod-" & $i Next _GUICtrlListView_DeleteAllItems($cLV_2) ;close it within the UDF _GUIListViewEx_Close(2) ;reload the ListView with the new data _GUICtrlListView_AddArray($cLV_2, $rstArray_2) $iLV_2 = _GUIListViewEx_Init($cLV_2) ;Local $arrr[2][2] = [[1, "A"], [2, "B"]] ;_GUIListViewEx_Insert ($arrr) GUISetState (@SW_SHOW, $hGUI2) _GUIListViewEx_SetActive($iLV_2) EndIf Next EndIf EndFunc Edited September 30, 2018 by robertocm
Moderators Melba23 Posted October 1, 2018 Author Moderators Posted October 1, 2018 robertocm, I see the problem and I am working on it. Why do you insist on using the keys all the time - Windows is a GUI and using the mouse to select gives the correct result! 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
robertocm Posted October 1, 2018 Posted October 1, 2018 Dear Melba23, Many Thanks! For me the UDF is totally functional, and taking a lot of advantage of it but when seeing some detail i prefer to comment, having 2 working options for the same result improves accesibility (if one option fails or cannot be used)
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