Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
- ; #include <Constants.au3> ; Only for _UserFunc
- ; UDF example begins here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #include <GuiListView.au3>
- Global $aArray[50][3]
- For $i = 0 To UBound($aArray) - 1
- For $j = 0 To UBound($aArray, 2) - 1
- $aArray[$i][$j] = StringReplace(StringFormat("%0" & Random(0, 9, 1) & "d", "0"), "0", Random(0, 9, 1), 0, 2)
- Next
- Next
- _ArrayDisplay_Beta($aArray, 'Sorts in "Col 1"', '22:44', Default, Default, Default, Default, 0xDDFFDD, "_UserFunc")
- Func _UserFunc($aArray , $aSelected, $cListView, $hGUI)
- _GUICtrlListView_SimpleSort($cListView, True, 2)
- EndFunc
- _ArrayDisplay_Beta($aArray, 'Selects the column 1', '22:44', Default, Default, Default, Default, Default, "_UserFunc2")
- Func _UserFunc2($aArray , $aSelected, $cListView, $hGUI)
- _GUICtrlListView_SetSelectedColumn($cListView, 2)
- EndFunc
- _ArrayDisplay_Beta($aArray, 'Marks the red selected items', Default, Default, Default, Default, Default, Default, "_UserFunc3")
- Func _UserFunc3($aArray , $aSelected, $cListView, $hGUI)
- _GUICtrlListView_BeginUpdate($cListView)
- Local $aID = _GUICtrlListView_GetSelectedIndices($cListView, True)
- For $i = 1 To $aID[0]
- $iID = _GUICtrlListView_GetItemParam($cListView, $aID[$i])
- GUICtrlSetBkColor($iID, 0xFFCC99)
- Next
- _GUICtrlListView_EndUpdate($cListView)
- EndFunc
- _ArrayDisplay_Beta($aArray, 'Changes the style', '22:44', Default, Default, Default, Default, 0xFFFFC4, "_UserFunc4")
- Func _UserFunc4($aArray , $aSelected, $cListView, $hGUI)
- Static Local $a = 0
- $a += 1
- If $a = 1 Then
- _GUICtrlListView_SetExtendedListViewStyle($cListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_BORDERSELECT, $LVS_EX_CHECKBOXES))
- Local $iWidth = _GUICtrlListView_GetColumnWidth($cListView, 0)
- _GUICtrlListView_SetColumnWidth($cListView, 0, $iWidth + 20)
- Else
- Local $sMsg
- $iCount = _GUICtrlListView_GetItemCount($cListView)
- For $i = 0 To $iCount - 1
- If _GUICtrlListView_GetItemChecked($cListView, $i) Then
- $sMsg &= _GUICtrlListView_GetItemText($cListView, $i, 1) & @CRLF
- EndIf
- Next
- MsgBox(0, ';)', $sMsg, 0, $hGUI)
- EndIf
- EndFunc
- _ArrayDisplay_Beta($aArray, 'Highlight the number 5', '22:44', Default, Default, Default, Default, Default, "_UserFunc5")
- Func _UserFunc5($aArray , $aSelected, $cListView, $hGUI)
- Local $iID, $iCount = _GUICtrlListView_GetItemCount($cListView)
- For $i = 0 To $iCount - 1
- If StringInStr(_GUICtrlListView_GetItemText($cListView, $i, 1), '5') Then
- $iID = _GUICtrlListView_GetItemParam($cListView, $i)
- GUICtrlSetBkColor($iID, 0xFFDDDD)
- EndIf
- Next
- EndFunc
- ; UDF code begins here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Func _ArrayDisplay_Beta(Const ByRef $avArray, $sTitle = Default, $sArray_Range = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $iAlt_Color = Default, $sUser_Func = Default)
- Local Const $_ARRAYCONSTANT_MB_SYSTEMMODAL = 4096
- Local Const $_ARRAYCONSTANT_MB_ICONINFORMATION = 64
- Local Const $_ARRAYCONSTANT_MB_ICONERROR = 16
- Local Const $_ARRAYCONSTANT_MB_YESNO = 4
- Local Const $_ARRAYCONSTANT_IDYES = 6
- ; Default values
- If $sTitle = Default Then $sTitle = "ArrayDisplay"
- If $sArray_Range = Default Then $sArray_Range = ""
- If $iFlags = Default Then $iFlags = 0
- If $vUser_Separator = Default Then $vUser_Separator = ""
- If $sHeader = Default Then $sHeader = ""
- If $iMax_ColWidth = Default Then $iMax_ColWidth = 350
- If $iAlt_Color = Default Then $iAlt_Color = 0
- If $sUser_Func = Default Then $sUser_Func = ""
- ; Check valid array
- Local $sMsg = "", $iRet
- If IsArray($avArray) Then
- ; Dimension checking
- Local $iDimension = UBound($avArray, 0), $iRowCount = UBound($avArray, 1), $iColCount = UBound($avArray, 2)
- If $iDimension > 2 Then
- $sMsg = "Larger than 2D array passed to function"
- $iRet = 2
- EndIf
- Else
- $sMsg = "No array variable passed to function"
- $iRet = 1
- EndIf
- If $sMsg Then
- If BitAND($iFlags, 8) And MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
- "ArrayDisplay Error: " & $sTitle, $sMsg & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
- Exit
- Else
- Return SetError($iRet, 0, "")
- EndIf
- EndIf
- ; Check for transpose and column align
- Local $iTranspose = BitAND($iFlags, 1)
- Local $iColAlign = BitAND($iFlags, 6) ; 0 = Left (default); 2 = Right; 4 = Center
- ; Determine copy separator
- Local $iCW_ColWidth = Number($vUser_Separator)
- ; Add dimensions to title
- Local $sDisplayTitle = "[" & $iRowCount & "]"
- If $iDimension = 2 Then
- $sDisplayTitle &= "[" & $iColCount & "]"
- EndIf
- If $iTranspose Then $sDisplayTitle &= " Transposed"
- If $sTitle Then $sDisplayTitle &= " - " & $sTitle
- ; Separator handling
- Local $sAD_Separator = ChrW(0xFAB1)
- ; Set separator to use in this UDF and store existing one
- Local $sCurr_Separator = Opt("GUIDataSeparatorChar", $sAD_Separator)
- ; Set default user separator if required
- If $vUser_Separator = "" Then $vUser_Separator = $sCurr_Separator
- ; Declare variables
- Local $vTmp, $iRowLimit = 65526, $iColLimit = 250 ; Row = 64k control limit minus 4 buttons; Column - arbitrary limit
- ; Swap dimensions if transposing
- If $iColCount < 0 Then $iColCount = 0
- If $iTranspose Then
- $vTmp = $iRowCount
- $iRowCount = $iColCount
- $iColCount = $vTmp
- EndIf
- ; Set display limits for dimensions
- Local $iItem_Start = 0, $iItem_End = $iRowCount - 1, $iSubItem_Start = 0, $iSubItem_End = $iColCount - 1, $avDimSplit, $avRangeSplit
- ; Adjust for 1D array
- If $iDimension = 1 Then
- If $iTranspose Then
- $iItem_End = 0
- Else
- $iSubItem_End = 0
- EndIf
- EndIf
- ; Check for range set
- If $sArray_Range Then
- ; Force trailing | if required
- If (Not StringInStr($sArray_Range, "|")) Then
- $sArray_Range &= "|"
- EndIf
- ; Split into row|col
- $avDimSplit = StringSplit($sArray_Range, "|")
- ; Check valid ranges
- If Not @error Then
- $avRangeSplit = StringSplit($avDimSplit[1], ":")
- If @error Then
- $iItem_Start = 0
- If Number($avRangeSplit[1]) Then
- $iItem_End = Number($avRangeSplit[1])
- EndIf
- Else
- $iItem_Start = Number($avRangeSplit[1])
- If Number($avRangeSplit[2]) Then
- $iItem_End = Number($avRangeSplit[2])
- EndIf
- EndIf
- $avRangeSplit = StringSplit($avDimSplit[2], ":")
- If @error Then
- $iSubItem_Start = 0
- If Number($avRangeSplit[1]) Then
- $iSubItem_End = Number($avRangeSplit[1])
- EndIf
- Else
- $iSubItem_Start = Number($avRangeSplit[1])
- If Number($avRangeSplit[2]) Then
- $iSubItem_End = Number($avRangeSplit[2])
- EndIf
- EndIf
- ; Swap if tranposing
- If $iTranspose Then
- $vTmp = $iItem_Start
- $iItem_Start = $iSubItem_Start
- $iSubItem_Start = $vTmp
- $vTmp = $iItem_End
- $iItem_End = $iSubItem_End
- $iSubItem_End = $vTmp
- EndIf
- ; Check limits
- If $iItem_Start < 0 Then $iItem_Start = 0
- If $iSubItem_Start < 0 Then $iSubItem_Start = 0
- If $iItem_End > $iRowCount - 1 Then $iItem_End = $iRowCount - 1
- If $iSubItem_End > $iColCount - 1 Then $iSubItem_End = $iColCount - 1
- EndIf
- EndIf
- ; Check if array will be truncated
- $sMsg = ""
- If $iItem_End - $iItem_Start > $iRowLimit Then
- $sMsg = "Array truncated - maximum " & $iRowLimit & " rows will be displayed"
- $iItem_End = $iItem_Start + $iRowLimit - 1
- EndIf
- If $iSubItem_End - $iSubItem_Start > $iColLimit Then
- If $sMsg Then $sMsg &= @CRLF & @CRLF
- $sMsg &= "Array truncated - maximum " & $iColLimit & " columns will be displayed"
- $iSubItem_End = $iSubItem_Start + $iColLimit - 1
- EndIf
- ; Split custom header on separator
- Local $asHeader = StringSplit($sHeader, $sCurr_Separator, 2) ; No count element
- $sHeader = "Row"
- ; Create custom header with available items
- If $asHeader[0] Then
- ; Set as many as available
- For $i = $iSubItem_Start To $iSubItem_End
- ; Check custom header available
- If $i >= UBound($asHeader) Then ExitLoop
- $sHeader &= $sAD_Separator & $asHeader[$i]
- Next
- Else
- ; Set default start
- $i = $iSubItem_Start
- EndIf
- ; Add default headers to fill to end
- For $j = $i To $iSubItem_End
- $sHeader &= $sAD_Separator & "Col " & $j
- Next
- ; Convert array into ListViewItem compatible lines
- Local $avArrayText[$iItem_End - $iItem_Start + 1]
- For $i = $iItem_Start To $iItem_End
- $avArrayText[$i - $iItem_Start] = "[" & $i & "]"
- For $j = $iSubItem_Start To $iSubItem_End
- ; Get current item
- If $iDimension = 1 Then
- If $iTranspose Then
- $vTmp = $avArray[$j]
- Else
- $vTmp = $avArray[$i]
- EndIf
- Else
- If $iTranspose Then
- $vTmp = $avArray[$j][$i]
- Else
- $vTmp = $avArray[$i][$j]
- EndIf
- EndIf
- $avArrayText[$i - $iItem_Start] &= $sAD_Separator & $vTmp
- Next
- Next
- ; GUI Constants
- Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64
- Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102
- Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 512
- Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 2
- Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 4
- Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3
- Local Const $_ARRAYCONSTANT_GUI_DISABLE = 128
- Local Const $_ARRAYCONSTANT_GUI_FOCUS = 256
- ; Local Const $_ARRAYCONSTANT_GUI_BKCOLOR_LV_ALTERNATE = 0xFE000000
- Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4)
- Local Const $_ARRAYCONSTANT_LVM_GETITEMRECT = (0x1000 + 14)
- Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29)
- Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30)
- Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44)
- Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54)
- Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1
- Local Const $_ARRAYCONSTANT_LVIS_SELECTED = 0x2
- Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8
- Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20
- Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200
- Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000
- Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000
- Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000
- Local Const $_ARRAYCONSTANT_WM_SETREDRAW = 11
- Local Const $_ARRAYCONSTANT_LVSCW_AUTOSIZE = -1
- ; Create GUI
- Local $iOrgWidth = 200, $iHeight = 200, $iMinSize = 250
- Local $hGUI = GUICreate($sDisplayTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX))
- Local $aiGUISize = WinGetClientSize($hGUI)
- Local $iButtonWidth = $aiGUISize[0] / 2
- ; Create ListView
- Local $cListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 46, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS)
- ; GUICtrlSetBkColor($cListView, $_ARRAYCONSTANT_GUI_BKCOLOR_LV_ALTERNATE)
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES)
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT)
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE)
- ; Create buttons
- Local $cCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiGUISize[1] - 43, $iButtonWidth, 20)
- Local $cCopy_Data = GUICtrlCreateButton("Copy Data Only", $iButtonWidth, $aiGUISize[1] - 43, $iButtonWidth, 20)
- Local $cUser_Func = GUICtrlCreateButton("Run User Function", 0, $aiGUISize[1] - 23, $iButtonWidth, 20)
- If Not $sUser_Func Then GUICtrlSetState($cUser_Func, $_ARRAYCONSTANT_GUI_DISABLE)
- Local $cExit_Script = GUICtrlCreateButton("Exit Script", $iButtonWidth, $aiGUISize[1] - 23, $iButtonWidth, 20)
- ; Set resizing
- GUICtrlSetResizing($cListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS)
- GUICtrlSetResizing($cCopy_ID, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
- GUICtrlSetResizing($cCopy_Data, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
- GUICtrlSetResizing($cUser_Func, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
- GUICtrlSetResizing($cExit_Script, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
- ; Start ListView update
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0)
- ; Fill listview
- Local $odd = False
- Local $cItem
- For $i = 0 To UBound($avArrayText) - 1
- $cItem = GUICtrlCreateListViewItem($avArrayText[$i], $cListView)
- If $iAlt_Color Then
- If $odd Then GUICtrlSetBkColor($cItem, $iAlt_Color)
- $odd = Not $odd
- EndIf
- Next
- ; Align columns if required - $iColAlign = 2 for Right and 4 for Center
- If $iColAlign Then
- Local Const $_ARRAYCONSTANT_LVCF_FMT = 0x01
- Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNW = (0x1000 + 96)
- Local $tColumn = DllStructCreate("uint Mask;int Fmt;int CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal")
- DllStructSetData($tColumn, "Mask", $_ARRAYCONSTANT_LVCF_FMT)
- DllStructSetData($tColumn, "Fmt", $iColAlign / 2) ; Left = 0; Right = 1; Center = 2
- Local $pColumn = DllStructGetPtr($tColumn)
- ; Loop through columns
- For $i = 1 To $iSubItem_End - $iSubItem_Start + 1
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETCOLUMNW, $i, $pColumn)
- Next
- EndIf
- ; End ListView update
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0)
- ; Allow for borders with and without vertical scrollbar
- Local $iBorder = 45
- If UBound($avArrayText) > 20 Then
- $iBorder += 20
- EndIf
- ; Adjust dialog width
- Local $iWidth = $iBorder, $iColWidth = 0, $aiColWidth[$iColCount + 2], $iMin_ColWidth = 50
- ; Get required column widths to fit items
- For $i = 0 To $iSubItem_End - $iSubItem_Start + 1
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE)
- $iColWidth = GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
- ; Set minimum if required
- If $iColWidth < $iMin_ColWidth Then
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth)
- $iColWidth = $iMin_ColWidth
- EndIf
- ; Add to total width
- $iWidth += $iColWidth
- ; Store value
- $aiColWidth[$i] = $iColWidth
- Next
- ; Now check max size
- If $iWidth > @DesktopWidth - 100 Then
- ; Apply max col width limit to reduce width
- $iWidth = $iBorder
- For $i = 0 To $iSubItem_End - $iSubItem_Start + 1
- If $aiColWidth[$i] > $iMax_ColWidth Then
- ; Reset width
- GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth)
- $iWidth += $iMax_ColWidth
- Else
- ; Retain width
- $iWidth += $aiColWidth[$i]
- EndIf
- Next
- EndIf
- ; Check max/min width
- If $iWidth > @DesktopWidth - 100 Then
- $iWidth = @DesktopWidth - 100
- ElseIf $iWidth < $iMinSize Then
- $iWidth = $iMinSize
- EndIf
- ; Get row height
- Local $tRect = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct")
- DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($cListView), "uint", $_ARRAYCONSTANT_LVM_GETITEMRECT, "wparam", 0, "struct*", $tRect)
- ; Set required GUI height
- Local $aiWin_Pos = WinGetPos($hGUI)
- Local $aiLV_Pos = ControlGetPos($hGUI, "", $cListView)
- $iHeight = ((UBound($avArrayText) + 3) * (DllStructGetData($tRect, "Bottom") - DllStructGetData($tRect, "Top"))) + $aiWin_Pos[3] - $aiLV_Pos[3]
- ; Check min/max height
- If $iHeight > @DesktopHeight - 100 Then
- $iHeight = @DesktopHeight - 100
- ElseIf $iHeight < $iMinSize Then
- $iHeight = $iMinSize
- EndIf
- ; Display and resize dialog
- GUISetState(@SW_HIDE, $hGUI)
- WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, (@DesktopHeight - $iHeight) / 2, $iWidth, $iHeight)
- GUISetState(@SW_SHOW, $hGUI)
- ; Announce if array was truncated
- If $sMsg Then
- MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONINFORMATION, "Array truncated", $sMsg, 0, $hGUI)
- EndIf
- ; Switch to GetMessage mode
- Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg
- While 1
- $iMsg = GUIGetMsg() ; Variable needed to check which "Copy" button was pressed
- Switch $iMsg
- Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE
- ExitLoop
- Case $cCopy_ID, $cCopy_Data
- ; Count selected rows
- Local $iSel_Count = GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_GETSELECTEDCOUNT, 0, 0)
- ; Display splash dialog if required
- If Not ($iSel_Count) And ($iItem_End - $iItem_Start) * ($iSubItem_End - $iSubItem_Start) > 10000 Then
- SplashTextOn("ArrayDisplay", "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100)
- EndIf
- ; Generate clipboard text
- Local $sClip = "", $sItem, $aSplit
- ; Add items
- For $i = 0 To $iItem_End - $iItem_Start
- ; Skip if copying selected rows and item not selected
- If $iSel_Count And Not (GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED)) Then
- ContinueLoop
- EndIf
- $sItem = $avArrayText[$i]
- If $iMsg = $cCopy_Data Then
- ; Remove row ID if required
- $sItem = StringRegExpReplace($sItem, "^\[\d+\].(.*)$", "$1")
- EndIf
- If $iCW_ColWidth Then
- ; Expand columns
- $aSplit = StringSplit($sItem, $sAD_Separator)
- $sItem = ""
- For $j = 1 To $aSplit[0]
- $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth))
- Next
- Else
- ; Use defined separator
- $sItem = StringReplace($sItem, $sAD_Separator, $vUser_Separator)
- EndIf
- $sClip &= $sItem & @CRLF
- Next
- ; Add header line if required
- If $iMsg = $cCopy_ID Then
- If $iCW_ColWidth Then
- $aSplit = StringSplit($sHeader, $sAD_Separator)
- $sItem = ""
- For $j = 1 To $aSplit[0]
- $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth))
- Next
- Else
- $sItem = StringReplace($sHeader, $sAD_Separator, $vUser_Separator)
- EndIf
- $sClip = $sItem & @CRLF & $sClip
- EndIf
- ;Send to clipboard
- ClipPut($sClip)
- ; Remove splash if used
- SplashOff()
- ; Refocus ListView
- GUICtrlSetState($cListView, $_ARRAYCONSTANT_GUI_FOCUS)
- Case $cUser_Func
- ; Get selected indices
- Local $aiSelItems[$iRowLimit] = [0]
- For $i = 0 To GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
- If GUICtrlSendMsg($cListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED) Then
- $aiSelItems[0] += 1
- $aiSelItems[$aiSelItems[0]] = $i + $iItem_Start
- EndIf
- Next
- ReDim $aiSelItems[$aiSelItems[0] + 1]
- ; Pass array and selection to user function
- Call($sUser_Func, $avArray, $aiSelItems, $cListView, $hGUI)
- GUICtrlSetState($cListView, $_ARRAYCONSTANT_GUI_FOCUS)
- Case $cExit_Script
- Exit
- EndSwitch
- WEnd
- ; Clear up
- GUIDelete($hGUI)
- Opt("GUIOnEventMode", $iOnEventMode) ; Reset original GUI mode
- Opt("GUIDataSeparatorChar", $sCurr_Separator) ; Reset original separator
- Return 1
- EndFunc ;==>_ArrayDisplay_Beta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement