#include #include #include "GUIListViewEx_EventMonitor.au3" #include ; Just for display in example Global $iCount_Left = 20, $iCount_Right = 20, $vData, $aRet, $iEditMode = 0 ; Create GUI $hGUI = GUICreate("LVEx Example 2", 640, 430) ; Create Left ListView GUICtrlCreateLabel("Native ListView", 10, 5, 300, 35) $cListView_Left = GUICtrlCreateListView("Tom", 10, 40, 250, 300, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) _GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cListView_Left, 0, 229) ; Create array and fill Left listview Global $aLV_List_Left[$iCount_Left + 1] = [$iCount_Left] For $i = 1 To UBound($aLV_List_Left) - 1 $aLV_List_Left[$i] = "Tom " & $i - 1 GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left) Next ; Initiate LVEx - count parameter set - blue insert mark- no drag image $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False) ; Column 0 editable with readonly combo _GUIListViewEx_SetEditStatus($iLV_Left_Index, 0, 2, "Fred|Dick|Harry with a very long name that will not fit in the column", True) ; Set combo dropdown width - use my StringSize UDF to get the correct value Local $aWidth[1] = [320] _GUIListViewEx_EditWidth($iLV_Left_Index, $aWidth) ; Initialise tooltip to display 0 column item content for 2 secs when clicked _GUIListViewEx_ToolTipInit($iLV_Left_Index, "*", 2000) ; Create Right ListView GUICtrlCreateLabel("UDF ListView", 380, 5, 300, 35) $hListView_Right = _GUICtrlListView_Create($hGUI, "Peter", 380, 40, 250, 300, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($hListView_Right, 0, 229) _GUICtrlListView_SetInsertMarkColor($hListView_Right, 0) ; Create array and fill listview Global $aLV_List_Right[$iCount_Right] For $i = 0 To UBound($aLV_List_Right) - 1 $aLV_List_Right[$i] = "Peter " & $i _GUICtrlListView_AddItem($hListView_Right, $aLV_List_Right[$i]) Next ; Initiate LVEx - no count - green insert parameter - no drag image $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 0, 0x00FF00) ; Create Edit Mode Combos GUICtrlCreateLabel("Edit Modes", 280, 50, 60, 20) GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 280, 70, 10, 80) GUICtrlCreateLabel(": Single Edit" & @CRLF & ": Exit Edge" & @CRLF & ": Stay Edge" & @CRLF & ": Loop Edge", 290, 70, 65, 80) GUICtrlCreateLabel("Row Mode", 280, 140, 60, 20) $cCombo_Row = GUICtrlCreateCombo("", 280, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Row, "0|1|2|3", 0) GUICtrlCreateLabel("Col Mode", 280, 200, 60, 20) $cCombo_Col = GUICtrlCreateCombo("", 280, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Col, "0|1|2|3", 0) GUICtrlCreateLabel("ESC Mode", 280, 260, 75, 20) $cCombo_Reset = GUICtrlCreateCombo("", 280, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit") ; Create buttons $cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30) $cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30) $cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30) $cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30) $cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30) $cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30) $cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 30) GUISetState() ; Register for dragging and editing _GUIListViewEx_MsgRegister() ; Set the right ListView as active _GUIListViewEx_SetActive(2) Switch _GUIListViewEx_GetActive() Case 0 $sMsg = "No ListView is active" Case 1 $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------" Case 2 $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->" EndSwitch MsgBox(0, "Active ListView", $sMsg) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $cExit_Button Exit Case $cInsert_Button ; Prepare data for insertion Switch $aGLVEx_Data[0][1] Case 1 ; Array format with single column native ListView Global $vData[1] = ["Tom " & $iCount_Left] $iCount_Left += 1 _GUIListViewEx_Insert($vData) Case 2 ; String format with single column UDF ListView $vData = "Peter " & $iCount_Right $iCount_Right += 1 _GUIListViewEx_Insert($vData) EndSwitch Case $cDelete_Button ;~ _GUIListViewEx_Delete() _GUICtrlListView_DeleteAllItems($cListView_Left) _GUIListViewEx_Close($iLV_Left_Index) ReDim $aLV_List_Left[0] $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False) _GUIListViewEx_ToolTipInit($iLV_Left_Index, "*", 2000) $aRunSiteTestCasesSelected = _GUIListViewEx_ReturnArray($iLV_Left_Index) Case $cUp_Button _GUIListViewEx_Up() Case $cDown_Button _GUIListViewEx_Down() Case $cDisplay_Left_Button $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index) If Not @error Then _ArrayDisplay($aLV_List_Left, "Returned Left") Else MsgBox(0, "Left", "Empty Array") EndIf Case $cDisplay_Right_Button $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index) If Not @error Then _ArrayDisplay($aLV_List_Right, "Returned Right") Else MsgBox(0, "Right", "Empty Array") EndIf Case $cCombo_Row Switch GUICtrlRead($cCombo_Row) Case 0 GUICtrlSetData($cCombo_Col, 0) Case Else If GUICtrlRead($cCombo_Col) = 0 Then GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row)) EndIf EndSwitch $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col)) Case $cCombo_Col Switch GUICtrlRead($cCombo_Col) Case 0 GUICtrlSetData($cCombo_Row, 0) Case Else If GUICtrlRead($cCombo_Row) = 0 Then GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col)) EndIf EndSwitch $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col)) Case $cCombo_Reset ; Toggle edit mode value to switch ESC modes $iEditMode *= -1 EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) ; Use combos to change EditMode If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 ; No event detected Case 1 If $vRet = "" Then MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) EndIf Case 2 If $vRet = "" Then MsgBox($MB_SYSTEMMODAL, "Header edit", "Header edit aborted" & @CRLF) Else _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " header edited", Default, 8) EndIf Case 3 MsgBox($MB_SYSTEMMODAL, "Sorted", "ListView: " & $vRet & @CRLF) Case 4 MsgBox($MB_SYSTEMMODAL, "Dragged", "From : To" & @CRLF & $vRet & @CRLF) EndSwitch WEnd