Jump to content

Some thinking about _ArrayDisplay

Recommended Posts

Just some thinking to make the _debugArrayDisplay neater, and _ArrayDispaly more flexible.

_debugArrayDisplay's buttons that looks weird, moreover, only one button can be user defined.  _ArrayDisplay does not allow to hook up with something else, unless create a customized ArrayDisplayInternal.

Is it possible to extend the usage for _ArrayDisplay by separate two functions before and after GUISetState(@SW_SHOW) -- _ArrayDisplayInit to return an array of handles of components, _ArrayDisplayRunn($aArrayOfHandleCallbackFlags), user can change property of the handles (like set background color), add contextmenu, etc as the preconfiguration stage between the two.

For _debugArrayDisplay, it would be much neater if buttons is moved into a contextmenu; and it is possibly more extensible if it accept an array of new menu item and callbacks.

The callback can still have two arguments (array and index), or additional handle/handles.

Edited by Ghost_Archer
Link to post
Share on other sites
  • Moderators


_ArrayDisplay is designed for a "quick look" at an array content - _DebugArrayDisplay for a more detailed examination of the content during script development. Think of them as the array equivalent of ConsoleWrite. And just like that function, neither are intended for interaction with an operational script - if you want that sort of functionality then you will need to write your own version.


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:


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 post
Share on other sites
20 hours ago, Ghost_Archer said:

_ArrayDisplay does not allow to hook up with something else, unless create a customized ArrayDisplayInternal.


4 hours ago, Melba23 said:

if you want that sort of functionality then you will need to write your own version.


Hi, I did this a year ago, tweaking ArrayDisplayInternals.au3 five times for personal use.
It required first to study __ArrayDisplay_Share(), gladly the function has great comments in it.
Here is the summary of the tweaks (first two are cosmetic), maybe it will give you some ideas in case you wanna tweak your own version.

1) Allow ArrayDisplay initial width to be larger than 210 (default) : cosmetic.
Useful if you got plenty of ArrayDisplay important titles in a script and they are cropped, then better start with an original width > 210, or you'll have to resize constantly each ArrayDisplay :

; In calling script
_ArrayDisplay($aArray, "Important title not cropped" & "<<<width>>>" & "300", ...)

; in __ArrayDisplay_Share()
; ==== pixelsearch insert 1a ====
Local $iPosChevrons = StringInStr($sTitle, "<<<width>>>") ; 0 when not found
If $iPosChevrons <> 0 Then
    Local $iForcedWidth = Number(StringMid($sTitle, $iPosChevrons + 11)) ; ex. $sTitle = "ArrayDisplay title<<<width>>>300" => 300
    $sTitle = StringLeft($sTitle, $iPosChevrons - 1) ; ex. $sTitle = "ArrayDisplay title<<<width>>>300" => "ArrayDisplay title"
; ===============================


; ==== pixelsearch change 1b ====
; Create GUI
; Local $iOrgWidth = 210, $iHeight = 200, $iMinSize = 250

Local $iOrgWidth = (($iPosChevrons = 0) ? (210) : ($iForcedWidth)), $iHeight = 200, $iMinSize = 250
; ===============================

2) ArrayDisplay GUI always on top : cosmetic (tired of the "seek & hide" game with ArrayDisplay GUI)

; ==== pixelsearch change 2 ====
; Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, _

Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, _
; ===============================

3) Allow a non-contiguous rows set to be displayed, for example rows 0, 2 and 9

; ==== pixelsearch insert 3a ====
Local $bFilter = False
If StringRight($sArrayRange, 1) = "," Then ; ex. "0,2,9," will filter on rows 0 & 2 & 9 : important "," at the end (+++)
    Local $aFilter = StringSplit(StringTrimRight($sArrayRange, 1), ",") ; remove last "," then Split on ","
    Local $bFilter = True, $iFilterInc = 0
    $sArrayRange = "" ; keep compatibility with original function code
; ===============================

As there are several parts of __ArrayDisplay_Share() involved in this, I only indicated the 1st part of the tweak, all following parts of the tweak are based on the test :

If $bFilter Then...


4) Right-click on a row calls an external function named "_ArrayDisplay_Is_Calling", with 2 parameters being the row content and the array title.
If the external function doesn't exist in the calling script, then right-click does nothing (as is in the original __ArrayDisplay_Share function) so the tweak(s) are compatible with any script using _ArrayDisplay

; ==== pixelsearch insert 4a ====
Case - 9 ; $GUI_EVENT_SECONDARYDOWN = - 9 (right click)
    Local $sTextRightClick = __ArrayDisplay_GetItemTextString2($idListView) ; no 2nd parameter => check if ANY row is selected
    If $sTextRightClick <> "" Then
        If $iCoordMode <> 1 Then Opt("GUICoordMode", $iCoordMode) ; reset user's Coord mode (before Call)
        If $iOnEventMode <> 0 Then Opt("GUIOnEventMode", $iOnEventMode) ; reset user's GUI mode (before Call)

        #ignorefunc _ArrayDisplay_Is_Calling ; Call() is great to call a function that may not exist without script fatal error (see help file)
        Call("_ArrayDisplay_Is_Calling", $sTitle, $sTextRightClick) ; @error = 0xDEAD and @extended = 0xBEEF if function does not exist or invalid number of parameters.
                                                                    ; don't test 0xDEAD and 0xBEEF to stay compatible with all scripts.

        If $iCoordMode <> 1 Then Opt("GUICoordMode", 1) ; Melba23's Coord mode (as defined much higher before While 1 loop)
        If $iOnEventMode <> 0 Then Opt("GUIOnEventMode", 0) ; Melba23's GetMessage mode (as defined just before While 1 loop)
; ===============================


; ==== pixelsearch insert 4b ====
Func __ArrayDisplay_GetItemTextString2($hWnd, $iItem = -1) ; based on _GUICtrlListView_GetItemTextString() in GuiListView.au3
                                                           ; and   on _GUICtrlListView_GetNextItem()  also in GuiListView.au3
    Local $sRow = "", $sSeparatorChar = Opt('GUIDataSeparatorChar'), $iSelected
    If $iItem = -1 Then
        $iSelected = GUICtrlSendMsg($hWnd, 0x1000 + 12, -1, 0x0002)   ; get current row selected
        If $iSelected = - 1 Then Return "" ; -1 if no row selected, i.e right click (in list view) in empty place or buttons or headers
        $iSelected = $iItem ; get row
    For $x = 0 To __ArrayDisplay_GetColumnCount($hWnd) - 1
        $sRow &= __ArrayDisplay_GetItemText($hWnd, $iSelected, $x) & $sSeparatorChar
    Return StringTrimRight($sRow, 1)
EndFunc   ;==>__ArrayDisplay_GetItemTextString2
; ===============================

In calling script :
; ====================================================
Func _ArrayDisplay_Is_Calling(Const $sTitle, $sTextRightClick) ; display image in GUI window (function usable for other purpose)
EndFunc ; _ArrayDisplay_Is_Calling()


5) DebugArrayDisplay : Exit button changed to Cancel Button (setting @extended to 101) and it will return to the script, so it gives more flexibility to the script, instead of a brutal exit.
Also, the label control indicating the number of rows is now clickable, showing also "Ok" in its caption.
"Ok / Cancel", we know where to click :)

; ==== pixelsearch change 5a ====
; $idExit_Script = GUICtrlCreateButton("Exit Script", $iOffset, $aiGUISize[1] - 20, $iButtonWidth_Var, 20)
; $idData_Label = GUICtrlCreateLabel($sDisplayData, 0, $aiGUISize[1] - 20, $iButtonWidth_Var, 18, BitOR($_ARRAYCONSTANT_SS_CENTER, $_ARRAYCONSTANT_SS_CENTERIMAGE))

$idExit_Script = GUICtrlCreateButton("Cancel", $iOffset, $aiGUISize[1] - 20, $iButtonWidth_Var, 20)
$idData_Label = GUICtrlCreateLabel("OK " & $sDisplayData, 0, $aiGUISize[1] - 20, $iButtonWidth_Var, 18, BitOR($_ARRAYCONSTANT_SS_CENTER, $_ARRAYCONSTANT_SS_CENTERIMAGE))
; ===============================


; ==== pixelsearch change 5b ====

Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE, $idData_Label ; Exitloop if Red X, Esc (if not deactivated), or left click $idData_Label
; ===============================


Case $idExit_Script
    ; Clear up

    ; ==== pixelsearch change 5c ====
    ; Exit

    Opt("GUICoordMode", $iCoordMode) ; Reset original Coord mode
    Opt("GUIOnEventMode", $iOnEventMode) ; Reset original GUI mode
    Return SetExtended(101, 1) ; @extended = 101 and Return 1 (my way to know in calling script what to do if @extended = 101)
    ; ===============================

In calling script, for example :

_DebugArrayDisplay($aListe_img, _
    $aListe_img[0] & " image" & (($aListe_img[0] = 1) ? ("") : ("s")) & " to resize", _
    "1:", 0, Default, "Image name", 940) ; _DebugArrayDisplay() HAD an 'Exit Script' button (tweaked it to a 'Cancel' button to return here with @extended = 101)
    ; note "1:" for fun => skip row 0 (contains number of images in Array)

If @extended = 101 Then Return - 1 ; requires my 5th tweak in __ArrayDisplay_Share() : user clicked on Cancel button in __ArrayDisplay_Share()


Now you may ask : what are you going to do when a new AutoIt release will appear ?
Well I guess I'll use (again) a utility named Beyond Compare to track the differences between the 2 original versions of __ArrayDisplay_Share(), then reinject the tweaks into the new __ArrayDisplay_Share()
It shouldn't be too difficult as all 5 tweaks got "delimiters" like ; ==== pixelsearch insert 4a ==== etc...

AutoIt is fun :ILA2:

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...