Jump to content

New _ArrayDisplay Beta code - comments and suggestions welcomed


Melba23
 Share

Recommended Posts

I wouldn't like browsing in a 64+K listing, debugging or not. Period.

Rather say it's inconvenient for your requirements and you prefer to code your own custom function evey time you need one. Feel free to do so but please don't force others into adhering to your own personal rules.

Considering we don't agree on this, let's look elsewhere now.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Equally, don't force your preference to use a debugging function for anything other than debugging.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Note that I didn't ask for any functional improvement. But now that Melba has done a very good job at it, I don't see why we should trash his work.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

The work is here in this thread, if people want to use it, it's available. It doesn't belong in the UDF.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Gentlemen,

Enough. If the pair of you want to argue do it via PM and please stop cluttering up this thread - which is to discuss the code as posted. Thanks you for your cooperation. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Isn't that what we're doing? Discussing whether it should be a replacement for the standard _ArrayDisplay function inside the Array.au3 file should be part of the discussion.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

about column width - i think it would be a good idea to not set any limit to it at all, if whole _ArrayDisplay() window does not break @ScreenWidth limit

also in same case (_ArrayDisplay() window does not break @DesktopWidth limit) results window should not have horizontal scrollbar.

on a side note - why use "Const ByRef $avArray" ? - after testing i did not get any difference in speed (randomly +/- 0.1 seconds to 13,9 seconds overall)  or consumed memory size (about 326Mb) on $avArray[64000][20] in contrast if i set just "$avArray" as funtion input. So - maybe just go without "Const ByRef" - it simply sets the excessive artificial restriction without bringing anything useful...

Link to comment
Share on other sites

  • Moderators

Iczer,

The column width limit of 350 pixels is pretty generous (on my display that is 60 characters) - and you can always increase it by using the $iMax_ColWidth parameter if you really need to. ;)

As to the use of Const ByRef this is what the next version of the Help file will say on the matter (my bolding):

 

"Declaring parameters as both ByRef and Const is useful when the large original variable must remain unchanged as AutoIt will return an error if the function attempts to alter it inadvertantly. The order of the keywords is not important, as long as they are both in front of the parameter they modify.

Entire arrays can be passed to functions (and returned from them) by simply using the array name without any brackets. Arrays should be passed to user-defined functions using the ByRef keyword to avoid the overhead of copying all the data in the array. Note that AutoIt only copies an array parameter if the contents are changed, so it is only in this case that ByRef offers an advantage, although it is recommended that to use it in all cases."

So while I agree with you in principle that using Const ByRef is not necessary, I feel that adding these keywords is good coding practice. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

All nice changes. Even if infrequently used I love options, why not also:

1) a timeout flag

2) a save to file flag

3) alternating shades

 

And the intent of the function matters little compared to its utility.  I use it in both production and test environments, as some moving targets are essentially in a constant state of debug.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

boththose,

Glad you like it. As to the requests:

- Timeout. It would mean adding yet another parameter, and as I still see the principal use as debugging, I am not sure of the utility of such a thing. If you can drum up some support for the idea I will consider it

- Save flag. The "Run User Function" button is there to do that if needed. I am persuaded that the only real use of this button is to save and so I will change the code so that the array and the selected rows are passed to the function. The user can then save as required from within that function.

- Alternating shades. I must say I like that in a ListView and do it in all my scripts - so I will look into it. But I am NOT adding a parameter to select the colours (I like the green shade as used in the old folding output paper) so people will have to change the value in the code itself if they want something different. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

About width limits - isn't it better ? Otherwise why i have wide screen monitor?

;#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 code begins here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include <Array.au3>

; Create an array to display
Global $aArray[200][5], $vVar = 0
For $i = 0 To UBound($aArray) - 1
    For $j = 0 To UBound($aArray, 2) - 1
        $aArray[$i][$j] = "Item " & StringFormat("%02i", $i) & StringFormat("%02i", $j)
    Next
Next
; And add a couple of long elements
$aArray[0][1] = "A longish element to show column expansion"
$aArray[0][2] = "A very much longer element to show that the column expansion is limited to prevent one single column taking over the entire dialog because of one extremely long element within it"

; Run the Beta to show it displays without problem
_ArrayDisplay_Beta($aArray, "New Beta code - note ability to use standard '|' separator in array elements", Default, Default, Default, Default, Default, "_UserFunc")

Func _ArrayDisplay_Beta( Const ByRef $avArray, $sTitle = Default, $iItemLimit = Default, $iTranspose = Default, $sUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $sUserFunc = Default)
;Local $ttt = TimerInit()
    Local Const $_ARRAYCONSTANT_MB_SYSTEMMODAL = 4096
    Local Const $_ARRAYCONSTANT_MB_ICONERROR = 16
    Local Const $_ARRAYCONSTANT_MB_YESNO = 4
    Local Const $_ARRAYCONSTANT_IDYES = 6

    If (Not IsArray($avArray)) Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "No array variable passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(1, 0, "")
        EndIf
    EndIf

    ; Default values
    If $sTitle = Default Then $sTitle = "Array: ListView Display"
    If $iItemLimit = Default Then $iItemLimit = -1
    If $iTranspose = Default Then $iTranspose = 0
    If $sUser_Separator = Default Then $sUser_Separator = ""
    If $sHeader = Default Then $sHeader = ""
    If $iMax_ColWidth = Default Then $iMax_ColWidth = 350
    If $sUserFunc = Default Then $sUserFunc = ""

    ; Dimension checking
    Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1
    If $iDimension > 2 Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "Larger than 2D array passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(2, 0, "")
        EndIf
    EndIf

    ; Separator handling
    Local $sAD_Separator = ChrW(0xF123)
    Local $sCurr_Separator = Opt("GUIDataSeparatorChar", $sAD_Separator) ; Set separator to use in this UDF and store existing one
    If $sUser_Separator = "" Then $sUser_Separator = $sCurr_Separator

    ; Declare variables
    Local $vTmp, $iColLimit = 250

    ; Swap dimensions if transposing
    If $iSubMax < 0 Then $iSubMax = 0
    If $iTranspose Then
        $vTmp = $iUBound
        $iUBound = $iSubMax
        $iSubMax = $vTmp
    EndIf

    ; Set limits for dimensions
    If $iSubMax > $iColLimit Then $iSubMax = $iColLimit
    If $iItemLimit < 1 Then $iItemLimit = $iUBound
    If $iUBound > $iItemLimit Then $iUBound = $iItemLimit

    ; Create header
    If $sHeader = "" Then
        $sHeader = "Row"
        For $i = 0 To $iSubMax
            $sHeader &= $sAD_Separator & "Col " & $i
        Next
    EndIf

    ; Convert array into ListViewItem compatible lines
    Local $avArrayText[$iUBound + 1]
    For $i = 0 To $iUBound
        $avArrayText[$i] = "[" & $i & "]"
        For $j = 0 To $iSubMax
            ; 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] &= $sAD_Separator & $vTmp
        Next
    Next

    ; GUI Constants
    Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102
    Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64
    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_LVM_GETCOLUMNWIDTH = (0x1000 + 29)
    Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44)
    Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54)
    Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20
    Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1
    Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8
    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 = 600, $iHeight = 480
    Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX))
    Local $aiGUISize = WinGetClientSize($hGUI)
    Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 46, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS)
    Local $cCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cCopy_Data = GUICtrlCreateButton("Copy Data Only", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cUser_Func = GUICtrlCreateButton("Run User Function", 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    Local $cExit_Script = GUICtrlCreateButton("Exit Script", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    GUICtrlSetResizing($hListView, $_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)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0)

    ; Fill listview
    For $i = 0 To $iUBound
        GUICtrlCreateListViewItem($avArrayText[$i], $hListView)
    Next
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0)

    ; Adjust dialog width
    Local $iWidth = 0, $iColWidth, $iMin_ColWidth = 50

;   $aiGUISize
    For $i = 0 To $iSubMax + 1
        GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE)
        $iColWidth = GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
        ; Check for max/min width limits
        If $aiGUISize[0] > @DesktopWidth And $iColWidth > $iMax_ColWidth Then; <<<<================================================================================== fully usie desktop width 
            GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth)
            $iWidth += $iMax_ColWidth
        ElseIf $iColWidth < $iMin_ColWidth Then
            GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth)
            $iWidth += $iMin_ColWidth
        Else
            $iWidth += $iColWidth
        EndIf
    Next
    ; Set min/max size
    If $iWidth < 250 Then $iWidth = 230
    If $iWidth > @DesktopWidth Then $iWidth = @DesktopWidth - 120
    ; Allow for borders
    $iWidth += 33; <<<<================================================================================================================== getting rid of scrollbar

    ; Display and resize dialog
    GUISetState(@SW_HIDE, $hGUI)
    WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, Default, $iWidth)
    GUISetState(@SW_SHOW, $hGUI)

    Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg, $sClip
;MsgBox(64,"",TimerDiff($ttt))
    While 1

        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE
                ExitLoop
            Case $cCopy_ID, $cCopy_Data
                $sClip = ""
                ; Get selected indices
                Local $aiCurItems[1] = [0]
                For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                    If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                        $aiCurItems[0] += 1
                        ReDim $aiCurItems[$aiCurItems[0] + 1]
                        $aiCurItems[$aiCurItems[0]] = $i
                    EndIf
                Next
                ; Generate clipboard text
                If Not $aiCurItems[0] Then
                    For $sItem In $avArrayText
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                Else
                    If $iMsg = $cCopy_ID Then
                        ; Add hdr line
                        $sClip = $sHeader & @CRLF
                    EndIf
                    For $i = 1 To UBound($aiCurItems) - 1
                        $sItem = $avArrayText[$aiCurItems[$i]]
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                EndIf
                ; Replace separator with required character
                $sClip = StringReplace($sClip, $sAD_Separator, $sUser_Separator)
                ; Send to clipboard
                ClipPut($sClip)
            Case $cUser_Func
                ; Check if function defined
                If $sUserFunc Then
                    ; Get selected indices
                    Local $aiCurItems2[1] = [0]
                    For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                        If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                            $aiCurItems2[0] += 1
                            ReDim $aiCurItems2[$aiCurItems2[0] + 1]
                            $aiCurItems2[$aiCurItems2[0]] = $i
                        EndIf
                    Next
                    Call($sUserFunc, $avArray, $aiCurItems2)
                EndIf
            Case $cExit_Script
                Exit
        EndSwitch
    WEnd
    GUIDelete($hGUI)

    Opt("GUIOnEventMode", $iOnEventMode)
    Opt("GUIDataSeparatorChar", $sCurr_Separator) ; Reset original separator

    Return 1

EndFunc   ;==>_ArrayDisplay_Beta

; UDF code ends here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func _UserFunc($aArray, $aSelected)
    MsgBox($MB_SYSTEMMODAL, "Hi", "Running the user defined function with " & @NumParams & " parameters.")
    For $i = 1 To $aSelected[0]
        ConsoleWrite($aSelected[$i] & "|" & $aArray[$aSelected[$i]][0] & @LF)
    Next

EndFunc   ;==>_UserFun

"Declaring parameters as both ByRef and Const is useful when the large original variable must remain unchanged as AutoIt will return an error if the function attempts to alter it inadvertantly"

- in that case ByRef Const parameters should be allowed in the function calling, not function parameters string ;) i don't see any possibility for function to make mess outside without ByRef parameter. Only for function development stage it's maybe useful, but UDF would be used wider than it.

Strange "good coding practice"  - it makes base UDF function non First-class function. Why? Actually i wanted to ask that in regard of all "_Array" functions.

Link to comment
Share on other sites

  • Moderators

Iczer,

Width limits. I do not understand your point at all. You want to check if the client area is wider then the screen (If $aiGUISize[0] > @DesktopWidth) when the dialog is created only 600 pixels wide. I cannot imagine anyone using a screen that small these days. Furthermore the section where you added that condition is also only interested in determining the required width of the ListView to see if it will fit in the dialog - the actual dialog is sized later (; Set min/max size) when you for some reason decide to add extra padding for the scrollbars. The scrollbars are inside the ListView, not the dialog GUI, so they have no effect on the overall dialog sizing. Can you explain more clearly or offer an example script to show why you are concerned at present? :huh:

ByRef Const. That is an argument that you should take up with the developers - of which I am not one - in a separate thread. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Hi,

New code in the first post. Changes are the possibility to have alternate row colours (and I did add a parameter ;)) and the passing of the array and an array of selected rows to the User function. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

:thumbsup:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Melba32

$aiGUISize[0] > @DesktopWidth And $iColWidth > $iMax_ColWidth Then

i added this so $iMax_ColWidth gets applied only in case of GUI size gets greater than @DesktopWidth. $aiGUISize array was used for simplicity (otherwise WinGetPos() is needed)  I got things messed up.

$iWidth += 33

is for getting rid of horizontal scrollbar - if $iWidth += 20 it was appearing in my case

so this would be more correct:

;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
 #include <WinAPI.au3>
#include <Constants.au3> ; Only for _UserFunc
#include <GuiListView.au3>
#include <WindowsConstants.au3>

; UDF code begins here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include <Array.au3>

; Create an array to display
Global $aArray[200][5], $vVar = 0
For $i = 0 To UBound($aArray) - 1
    For $j = 0 To UBound($aArray, 2) - 1
        $aArray[$i][$j] = "Item " & StringFormat("%02i", $i) & StringFormat("%02i", $j)
    Next
Next
; And add a couple of long elements
$aArray[0][1] = "A longish element to show column expansion"
$aArray[0][2] = "A very much longer element to show that the column expansion is limited to prevent one single column taking over the entire dialog because of one extremely long element within it"

; Run the Beta to show it displays without problem
_ArrayDisplay_Beta($aArray, "", Default, Default, Default, Default, Default, "_UserFunc")

Func _ArrayDisplay_Beta( Const ByRef $avArray, $sTitle = Default, $iItemLimit = Default, $iTranspose = Default, $sUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $sUserFunc = Default)
;Local $ttt = TimerInit()
    Local Const $_ARRAYCONSTANT_MB_SYSTEMMODAL = 4096
    Local Const $_ARRAYCONSTANT_MB_ICONERROR = 16
    Local Const $_ARRAYCONSTANT_MB_YESNO = 4
    Local Const $_ARRAYCONSTANT_IDYES = 6

    If (Not IsArray($avArray)) Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "No array variable passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(1, 0, "")
        EndIf
    EndIf

    ; Default values
    If $sTitle = Default Then $sTitle = "Array: ListView Display"
    If $iItemLimit = Default Then $iItemLimit = -1
    If $iTranspose = Default Then $iTranspose = 0
    If $sUser_Separator = Default Then $sUser_Separator = ""
    If $sHeader = Default Then $sHeader = ""
    If $iMax_ColWidth = Default Then $iMax_ColWidth = 350
    If $sUserFunc = Default Then $sUserFunc = ""

    ; Dimension checking
    Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1
    If $iDimension > 2 Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "Larger than 2D array passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(2, 0, "")
        EndIf
    EndIf

    ; Separator handling
    Local $sAD_Separator = ChrW(0xF123)
    Local $sCurr_Separator = Opt("GUIDataSeparatorChar", $sAD_Separator) ; Set separator to use in this UDF and store existing one
    If $sUser_Separator = "" Then $sUser_Separator = $sCurr_Separator

    ; Declare variables
    Local $vTmp, $iColLimit = 250

    ; Swap dimensions if transposing
    If $iSubMax < 0 Then $iSubMax = 0
    If $iTranspose Then
        $vTmp = $iUBound
        $iUBound = $iSubMax
        $iSubMax = $vTmp
    EndIf

    ; Set limits for dimensions
    If $iSubMax > $iColLimit Then $iSubMax = $iColLimit
    If $iItemLimit < 1 Then $iItemLimit = $iUBound
    If $iUBound > $iItemLimit Then $iUBound = $iItemLimit

    ; Create header
    If $sHeader = "" Then
        $sHeader = "Row"
        For $i = 0 To $iSubMax
            $sHeader &= $sAD_Separator & "Col " & $i
        Next
    EndIf

    ; Convert array into ListViewItem compatible lines
    Local $avArrayText[$iUBound + 1]
    For $i = 0 To $iUBound
        $avArrayText[$i] = "[" & $i & "]"
        For $j = 0 To $iSubMax
            ; 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] &= $sAD_Separator & $vTmp
        Next
    Next

    ; GUI Constants
    Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102
    Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64
    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_LVM_GETCOLUMNWIDTH = (0x1000 + 29)
    Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44)
    Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54)
    Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20
    Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1
    Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8
    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 = 600, $iHeight = 480
    Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX))
    Local $aiGUISize = WinGetClientSize($hGUI)
    Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 46, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS)
    Local $cCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cCopy_Data = GUICtrlCreateButton("Copy Data Only", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cUser_Func = GUICtrlCreateButton("Run User Function", 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    Local $cExit_Script = GUICtrlCreateButton("Exit Script", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    GUICtrlSetResizing($hListView, $_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)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0)

    ; Fill listview
    For $i = 0 To $iUBound
        GUICtrlCreateListViewItem($avArrayText[$i], $hListView)
    Next
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0)

    ; Adjust dialog width
    Local $iWidth = 0, $iColWidth, $iMin_ColWidth = 50

;   $aiGUISize
    For $i = 0 To $iSubMax + 1
        GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE)
        $iColWidth = GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
        ; Check for max/min width limits
        If $iColWidth < $iMin_ColWidth Then
            GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth)
            $iWidth += $iMin_ColWidth
        Else
            $iWidth += $iColWidth
        EndIf
    Next

    $aiGUISize2 = WinGetPos($hGUI)
    Local Const $SM_CXVSCROLL = 2
    Local Const $SM_CXFRAME = 32

    ; Set min/max size
    $iWidth += $aiGUISize2[2] - $aiGUISize[0] + _WinAPI_GetSystemMetrics ( $SM_CXVSCROLL ) + _WinAPI_GetSystemMetrics ( $SM_CXFRAME )

    Local $hDC = _WinAPI_GetDC($hGUI)
    Local $hFont = _SendMessage($hGUI, $WM_GETFONT)
    Local $hSelectObject = _WinAPI_SelectObject($hDC, $hFont)
    Local $tSIZE = _WinAPI_GetTextExtentPoint32($hDC, WinGetTitle($hGUI))
    _WinAPI_SelectObject($hDC, $hSelectObject)
    _WinAPI_ReleaseDC($hGUI, $hDC)

    Local Const $SM_CXMIN = 28
    $iMinWidth = _WinAPI_GetSystemMetrics ( $SM_CXMIN ) + DllStructGetData($tSIZE, 1)

    If $iWidth < $iMinWidth Then $iWidth = $iMinWidth

    If $iWidth > @DesktopWidth Then
        For $i = 0 To $iSubMax + 1
            $iColWidth = GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
            If $iColWidth > $iMax_ColWidth Then
                GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth)
                $iWidth -= $iColWidth - $iMax_ColWidth
            EndIf
        Next
        If $iWidth > @DesktopWidth Then $iWidth = @DesktopWidth - 120
    EndIf

    ; Display and resize dialog
    GUISetState(@SW_HIDE, $hGUI)
    WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, Default, $iWidth)
    GUISetState(@SW_SHOW, $hGUI)

    Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg, $sClip

    While 1

        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE
                ExitLoop
            Case $cCopy_ID, $cCopy_Data
                $sClip = ""
                ; Get selected indices
                Local $aiCurItems[1] = [0]
                For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                    If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                        $aiCurItems[0] += 1
                        ReDim $aiCurItems[$aiCurItems[0] + 1]
                        $aiCurItems[$aiCurItems[0]] = $i
                    EndIf
                Next
                ; Generate clipboard text
                If Not $aiCurItems[0] Then
                    For $sItem In $avArrayText
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                Else
                    If $iMsg = $cCopy_ID Then
                        ; Add hdr line
                        $sClip = $sHeader & @CRLF
                    EndIf
                    For $i = 1 To UBound($aiCurItems) - 1
                        $sItem = $avArrayText[$aiCurItems[$i]]
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                EndIf
                ; Replace separator with required character
                $sClip = StringReplace($sClip, $sAD_Separator, $sUser_Separator)
                ; Send to clipboard
                ClipPut($sClip)
            Case $cUser_Func
                ; Check if function defined
                If $sUserFunc Then
                    ; Get selected indices
                    Local $aiCurItems2[1] = [0]
                    For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                        If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                            $aiCurItems2[0] += 1
                            ReDim $aiCurItems2[$aiCurItems2[0] + 1]
                            $aiCurItems2[$aiCurItems2[0]] = $i
                        EndIf
                    Next
                    Call($sUserFunc, $avArray, $aiCurItems2)
                EndIf
            Case $cExit_Script
                Exit
        EndSwitch
    WEnd
    GUIDelete($hGUI)

    Opt("GUIOnEventMode", $iOnEventMode)
    Opt("GUIDataSeparatorChar", $sCurr_Separator) ; Reset original separator

    Return 1

EndFunc   ;==>_ArrayDisplay_Beta

; UDF code ends here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func _UserFunc($aArray, $aSelected)
    MsgBox($MB_SYSTEMMODAL, "Hi", "Running the user defined function with " & @NumParams & " parameters.")
    For $i = 1 To $aSelected[0]
        ConsoleWrite($aSelected[$i] & "|" & $aArray[$aSelected[$i]][0] & @LF)
    Next

EndFunc   ;==>_UserFun

Main points:

- different title lengths --> different $iMinWidth

- $iMax_ColWidth gets applied only in case of GUI size gets greater than @DesktopWidth

- if GUI size still greater than @DesktopWidth, horizontal scrollbar appear

Link to comment
Share on other sites

  • Moderators

Iczer,

I understand now - sorry for being so slow. I will look into your changes. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Nice!

it could be interesting merging the module found in >this old post as an addition of further functionality callable via a new button at the bottom of this _ArrayDisplay (or, eventually, via the user function call?)

>that module, is nearly mergeable as is, the functionalities are available via right clicking on the grid. (this few  #include are missing and must be added in that udf to work:
#include <ButtonConstants.au3>
#include <ListBoxConstants.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

edit: (after having read  post >#38 :D )

it could be interesting to use the >GUIListViewEx as an external editing feature via the user function call... I will try...

Edited by PincoPanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • Moderators

PincoPanco,

This Beta code is a proposed replacement for the standard _ArrayDisplay UDF and I am certainly not going to add edit functionality into the code. But as czardas has pointed out, editable ListViews (and a lot more than that) are already available courtesy of my GUIListViewEx UDF. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Timeout. It would mean adding yet another parameter, and as I still see the principal use as debugging, I am not sure of the utility of such a thing. If you can drum up some support for the idea I will consider it

 

 

currently i use toast, previous to that tooltips, previous to that the console.  For the purpose of presenting me data while something else is occuring.  The console and tooltips filled up quick, and required me formatting the input, so most of the time i selected just the most essential data.  toast allows me to present quite a bit more with a proper timeout.  And I suppose I fall into the too lazy to build a listview (but only because the other alternatives are still reasonable).  _ArrayDisplay that allows progression without user interaction would let me just dump everything to the window and continue being lazy.  

So maybe  a timeout is incorrect, how about a 'Dont Block' parameter, while your busy not adding those :)

Now on to drumming up support for lazy.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...