Jump to content

GUI with many controls - Not loading when 1000+ and Scroll function freezing


MilenP
 Share

Recommended Posts

Hello AutoIt community,

 

I am beginner with the AutoIt automation, but I find it very useful.

Recently I was working on a tool, that is gathering big load of data and adding it in a GUI Form.

1. The  first issue is starting when the controls are getting more than 1000 (and what I can see, they have to be more than 4000). The creating buttons is starting to get very slow and even freeze once the controls are getting over 1000 (In my example below when the Global $iteration = 300)

2. The second issue is when the Form is created with for example 80 rows in the GUI (Global $iteration = 80). When I scroll, using the mouse wheel or dragging the scroll panel, the whole computer is freezing for some time.

 

I would like to ask if someone is able to assist me in optimizing the code in order to work correctly (to work at all :) )

 

Below you can find the issued part of the code, that I converted just for adding it here. I think when starting it you can see what I am talking about.

;~ ========================
;~ Milen Palavrov
;~ Editor: Milen Palavrov
;~ ========================
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
;~ ===
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <INet.au3>
#include <String.au3>
#include <Excel.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <GUIScroll.au3>
#include <ComboConstants.au3>
#include <JSON.au3>
#include <ColorConstants.au3>
#include <GUIHyperLink.au3>
;#include <GUIScrollBars.au3>
;#include <ScrollBarConstants.au3>
;#include <GUIScrollbars_Size.au3>
#include <GUIScrollbars_Ex.au3>

Global $iteration = 80

Global $stringToAdd = 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & _
                    '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry' & '|' & 'TestEntry'
Global $arrayTest[0][16]
Global $g_asFinalArrayAll[0][25]

for $i = 0 to $iteration
    _ArrayAdd($arrayTest, $stringToAdd)
Next

Global $hGuiFormConditionsAll = GUICreate("NewRelic Update Conditions All", 1450, 130 + (48 / 2) * 20, -1, -1)
Global $Color = 0xD3F6E0 ;light green color. When new value is added for the input  boxes.


    Local $countConditions = UBound($arrayTest)
    Local $scrollSize = ($countConditions * 25) + 160


    ;Global $updateConditionsAll = GUICtrlCreateTab(8, 8, 690, 600, BitOr($WS_EX_OVERLAPPEDWINDOW, $WS_VSCROLL))

    GUICtrlSetState(-1, $GUI_SHOW) ; will be display first

    WinActivate($hGuiFormConditionsAll)

    Global $labelButtonPoliciesAll[$countConditions]
    Global $labelButtonConditionsAll[$countConditions]
    Global $inputSelectValueAll[$countConditions]

    Global $inputButtonCriticalValueAll[$countConditions]
    Global $inputButtonCriticalDurationAll[$countConditions]
    Global $inputButtonWarningValueAll[$countConditions]
    Global $inputButtonWarningDurationAll[$countConditions]
    Global $inputButtonWhereClauseAll[$countConditions]

    Global $labelCriticalAll[$countConditions]
    Global $labelWarningAll[$countConditions]

    Global $inputEntityNameAll[$countConditions]

    Global $checkboxButtonStatusAll[$countConditions]

    $idUpdateAll = GUICtrlCreateButton("Update", 700, $scrollSize - 40, 75, 25)
    GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")

    Local $textPoliciesAll = GUICtrlCreateLabel('Policy Name', 18, 5, 200)
    GUICtrlSetFont($textPoliciesAll, 11, 600)
    Local $textConditionsAll = GUICtrlCreateLabel('Condition Name', 238, 5, 280)
    GUICtrlSetFont($textConditionsAll, 11, 600)

    Local $textSelectValueAll = GUICtrlCreateLabel('Selected Value', 538, 5, 150)
    GUICtrlSetFont($textSelectValueAll, 11, 600)

    Local $textCriticalTreshold1All = GUICtrlCreateLabel('Critical Treshold', 708, 5, 160)
    GUICtrlSetFont($textCriticalTreshold1All, 11, 600)
    Local $textCriticalTreshold2All = GUICtrlCreateLabel('  Value - Duration', 710, 30, 160)
    GUICtrlSetFont($textCriticalTreshold2All, 11, 300, $GUI_FONTITALIC)

    Local $textWarningTreshold1All = GUICtrlCreateLabel('Warning Treshold', 883, 5, 160)
    GUICtrlSetFont($textWarningTreshold1All, 11, 600)
    Local $textWarningTreshold2All = GUICtrlCreateLabel('   Value - Duration', 885, 30, 160)
    GUICtrlSetFont($textWarningTreshold2All, 11, 300, $GUI_FONTITALIC)

    Local $textWhereClauseAll = GUICtrlCreateLabel('Where', 1058, 5, 100)
    GUICtrlSetFont($textWhereClauseAll, 11, 600)
    Local $textWhereClause2All = GUICtrlCreateLabel('Clause', 1058, 30, 100)
    GUICtrlSetFont($textWhereClause2All, 11, 600)

    Local $textEntityNameAll = GUICtrlCreateLabel('Entity', 1178, 5, 100)
    GUICtrlSetFont($textEntityNameAll, 11, 600)
    Local $textEntityName2All = GUICtrlCreateLabel('Name(s)', 1178, 30, 100)
    GUICtrlSetFont($textEntityName2All, 11, 600)

    Local $textStatusAll = GUICtrlCreateLabel('Status', 1298, 5, 70)
    GUICtrlSetFont($textStatusAll, 11, 600)

    $checkboxSelectAllStatusAll = GUICtrlCreateCheckbox('Select all', 1310, 50, 90)
    GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")

For $j = 1 To $countConditions

        ;Sleep (200)
        $ClassList = StringSplit(StringTrimRight(WinGetClassList($hGuiFormConditionsAll),1),@LF)
        SplashTextOn('', 'Create Form' & @CRLF & $j & ' out of ' &  $countConditions & @CRLF & 'controls count - ' & UBound($ClassList) & @CRLF & "Policy - " & _
                    $arrayTest[$j - 1][4] & @LF & 'Condition - ' & $arrayTest[$j - 1][0], 300, 130, 1, 1, $DLG_NOTITLE, 'Times New Roman', 10)
        Local $comparison = '-'
        If $arrayTest[$j - 1][12] = 'above' Then
            $comparison = ChrW(0x2191)
        ElseIf $arrayTest[$j - 1][12] = 'below' Then
            $comparison = ChrW(0x2193)
        EndIf

        Local $x = ($j - 1) * 25 + 80
        ;$labelButtonPoliciesAll[$j - 1] = GUICtrlCreateLabel($arrayConditions[$j - 1][4], 20, $x, 200)

        $labelButtonPoliciesAll[$j - 1] = _GUICtrlHyperLink_Create($arrayTest[$j - 1][4], 20, $x, 200, 20, 0x0000FF, 0x551A8B, _
                                            -1, 'https://google.com', 'Open Policy "' & $arrayTest[$j - 1][4] & _
                                            '" in browser', $hGuiFormConditionsAll) ; Label with hyperlink for the policies

        ;$labelButtonConditionsAll[$j - 1] = GUICtrlCreateLabel($arrayConditions[$j - 1][0], 240, $x, 280)


        $labelButtonConditionsAll[$j - 1] = _GUICtrlHyperLink_Create($arrayTest[$j - 1][0], 240, $x, 280, 20, 0x0000FF, 0x551A8B, _
                                            -1, 'https://google.com' , 'Open Condition "' & $arrayTest[$j - 1][0] & _
                                            '" from Policy "' & $arrayTest[$j - 1][4] & '" in browser', $hGuiFormConditionsAll) ; Label with hyperlink for the condition

        $inputSelectValueAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][5], 540, $x, 150, 20)

        $inputButtonCriticalValueAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][8], 710, $x, 70, 20, $ES_NUMBER)
        $labelCriticalAll[$j - 1] = GUICtrlCreateLabel($comparison, 785, $x, 5, 20)
        GUICtrlSetTip($labelCriticalAll[$j - 1], $arrayTest[$j - 1][12])
        $inputButtonCriticalDurationAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][9], 795, $x, 70, 20, $ES_NUMBER)
        $inputButtonWarningValueAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][6], 885, $x, 70, 20, $ES_NUMBER)
        $labelWarningAll[$j - 1] = GUICtrlCreateLabel($comparison, 960, $x, 5, 20)
        GUICtrlSetTip($labelWarningAll[$j - 1], $arrayTest[$j - 1][12])
        $inputButtonWarningDurationAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][7], 970, $x, 70, 20, $ES_NUMBER)

        $inputButtonWhereClauseAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][10], 1060, $x, 100, 20)

        $inputEntityNameAll[$j - 1] = GUICtrlCreateInput($arrayTest[$j - 1][11], 1180, $x, 100, 20)

        Local $statusTemp = 'disabled'
        If $arrayTest[$j - 1][2] = 'true' Then
            $statusTemp = 'enabled'
        EndIf

        $checkboxButtonStatusAll[$j - 1] = GUICtrlCreateCheckbox($statusTemp, 1300, $x, 70, 20)

        If $arrayTest[$j - 1][2] = 'true' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_CHECKED) ; Uncheck checkbox when Update button clicked
        ElseIf $arrayTest[$j - 1][2] = 'false' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_UNCHECKED) ; Uncheck checkbox when Update button clicked
        EndIf

        GUICtrlSetFont($labelButtonConditionsAll[$j - 1], 9)
        GUICtrlSetFont($inputButtonCriticalValueAll[$j - 1], 9)
        GUICtrlSetFont($labelButtonPoliciesAll, -1, -1, 2, -1)

        ;GUICtrlSetFont($checkboxButtonStatusAll[$j - 1], 9)

        $g_finalStringAll = $arrayTest[$j - 1][4] & '|' & $arrayTest[$j - 1][3] & '|' & $arrayTest[$j - 1][0] & _
                '|' & $arrayTest[$j - 1][1] & '|' & $arrayTest[$j - 1][5] & '|' & $arrayTest[$j - 1][8] & _
                '|' & $arrayTest[$j - 1][9] & '|' & $arrayTest[$j - 1][6] & '|' & $arrayTest[$j - 1][7] & _
                '|' & $arrayTest[$j - 1][2] & '|' & $arrayTest[$j - 1][10] & '|' & $arrayTest[$j - 1][11] & _
                '|' & $arrayTest[$j - 1][12] & '|' & $arrayTest[$j - 1][13] & '|' & $arrayTest[$j - 1][14] & _
                '|' & $arrayTest[$j - 1][15] & '|' & $inputSelectValueAll[$j - 1] & '|' & $inputButtonCriticalValueAll[$j - 1] & _
                '|' & $inputButtonCriticalDurationAll[$j - 1] & '|' & $inputButtonWarningValueAll[$j - 1] & '|' & $inputButtonWarningDurationAll[$j - 1] & _
                '|' & $inputButtonWhereClauseAll[$j - 1] & '|' & $inputEntityNameAll[$j - 1] & '|' & $checkboxButtonStatusAll[$j - 1] & _
                '|' & $idUpdateAll

        _ArrayAdd($g_asFinalArrayAll, $g_finalStringAll)

        If $arrayTest[$j - 1][0] = 'N/A' Then
            GUICtrlSetState($labelButtonConditionsAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonCriticalValueAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonCriticalValueAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonCriticalDurationAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonWarningValueAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonWarningDurationAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputEntityNameAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputButtonWhereClauseAll[$j - 1], $GUI_DISABLE)
            GUICtrlSetState($inputSelectValueAll[$j - 1], $GUI_DISABLE)
        EndIf

        If $arrayTest[$j - 1][11] = 'All' Then
            GUICtrlSetState($inputEntityNameAll[$j - 1], $GUI_DISABLE)
        EndIf

        If GUICtrlRead($inputSelectValueAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputSelectValueAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputButtonCriticalValueAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputButtonCriticalValueAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputButtonCriticalDurationAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputButtonCriticalDurationAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputButtonWarningValueAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputButtonWarningValueAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputButtonWarningDurationAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputButtonWarningDurationAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputButtonWhereClauseAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputButtonWhereClauseAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($inputEntityNameAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($inputEntityNameAll[$j - 1], $GUI_DISABLE)
        EndIf
        If GUICtrlRead($checkboxButtonStatusAll[$j - 1]) = 'N/A' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
        EndIf

        ;******** PREDEFINED CONDITIONS - START ********

        If $arrayTest[$j - 1][0] = 'CPU % (High)' And $arrayTest[$j - 1][4] = 'STG - IRIS' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            $tempLabel = GUICtrlCreateLabel('', 1300, $x, 70, 20)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetTip(-1, 'Agreed with Devs to be disabled. Too much CPU consumption by design.', Default, $TIP_INFOICON, $TIP_BALLOON)
        EndIf

        If $arrayTest[$j - 1][0] = 'CPU % (High)' And $arrayTest[$j - 1][4] = 'PROD - IRIS' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            $tempLabel = GUICtrlCreateLabel('', 1300, $x, 70, 20)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetTip(-1, 'Agreed with Devs to be disabled. Too much CPU consumption by design.', Default, $TIP_INFOICON, $TIP_BALLOON)
        EndIf

        If $arrayTest[$j - 1][0] = 'CPU % (High)' And $arrayTest[$j - 1][4] = 'Jenkins' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            $tempLabel = GUICtrlCreateLabel('', 1300, $x, 70, 20)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetTip(-1, 'Agreed with Devs to be disabled. Too much CPU consumption during deploy', Default, $TIP_INFOICON, $TIP_BALLOON)
        EndIf

        If $arrayTest[$j - 1][0] = 'Memory Used % (High)' And $arrayTest[$j - 1][4] = 'Jenkins' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            $tempLabel = GUICtrlCreateLabel('', 1300, $x, 70, 20)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetTip(-1, 'Agreed with Devs to be disabled. Too much Memory consumption during deploy', Default, $TIP_INFOICON, $TIP_BALLOON)
        EndIf

        If $arrayTest[$j - 1][0] = 'Memory Used % (High)' And $arrayTest[$j - 1][4] = 'STG - Memory Database' Then
            GUICtrlSetState($checkboxButtonStatusAll[$j - 1], $GUI_DISABLE)
            $tempLabel = GUICtrlCreateLabel('', 1300, $x, 70, 20)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetTip(-1, 'Agreed with Devs to be disabled. Too much Memory consumption by design', Default, $TIP_INFOICON, $TIP_BALLOON)
        EndIf

        ;******** PREDEFINED CONDITIONS - END ********
        Sleep (50)
    SplashOff()

Next

    Local $scrollSize = (UBound($arrayTest) * 25) + 160

    _ArraySort($g_asFinalArrayAll, 0, 0, 0, 1)
    _GUIScrollbars_Generate($hGuiFormConditionsAll, -1, $scrollSize)
    GUISetState(@SW_SHOW, $hGuiFormConditionsAll)

    While 1

    WEnd
    Sleep(250)

 

Thank you all in advance,

Link to comment
Share on other sites

  • Moderators

MilenP,

A quick look at the code makes me think that a ListView would be a better solution to your problem - a 300 row ListView with 16 or so columns is nowhere near excessive and removes the scroll problem at a stroke. You can use my GUIListViewEx UDF (look in my sig for the link) to make the elements editable or actionable if required - plus the entire content of the ListView is then easily accessible as an array whenever required.

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

Hi @Melba23,

 

I was not aware of this ListView and that it would do the job in my case, but I will play with it now. After I rework my code I think it will be perfect. Can you only advise if it is normal to be so slow after some control count is reached (or the reason is different). You can directly Play my code and see what I am talking about, but I guess you know, this is why you told me to use ListView (and wrote it :) )

Thank you again, I will give you feedback here when I'm ready with my code.

 

Link to comment
Share on other sites

Hi again,


I would like to add few more questions to the above :)

1. Is possible to have hyperlinks with GUIListViewEx ? (I want my first 2 columns to be hyperlinks.)

2. Can I have a checkbox for the last column (because currently I see it can be only on the first).

 

Thank you.

Link to comment
Share on other sites

  • Moderators

MilenP,

1. No - but you can run a user function when the element is double-clicked, which could use the string displayed in the element to open a link.

2. Again no - but you can have a combo appear on doubleclicking the last element which would allow the content to be toggled between "On/Off" values only.

Any help?

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

18 hours ago, Melba23 said:

MilenP,

A quick look at the code makes me think that a ListView would be a better solution to your problem - a 300 row ListView with 16 or so columns is nowhere near excessive and removes the scroll problem at a stroke. You can use my GUIListViewEx UDF (look in my sig for the link) to make the elements editable or actionable if required - plus the entire content of the ListView is then easily accessible as an array whenever required.

M23

Thank you for your tips. It would be perfect if you give me some short examples for this 2 things, but if not, I will try to make it.
Also can you please advise on my question in the above comment (for future reference, I will use now the ListView, but just want to understand why it is so heavy and not working correctly) 

Quote

Can you only advise if it is normal to be so slow after some control count is reached (or the reason is different)

 

Thank you,

Link to comment
Share on other sites

  • Moderators

MilenP,

Here is a quick example script to show how my UDF will allow you to do what you want:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include "GUIListViewEx.au3"

$hGUI = GUICreate("Test", 1220, 500)

; Create titles
GUICtrlCreateLabel('Policy Name', 20, 5, 200)
GUICtrlCreateLabel('Condition Name', 220, 5, 280)
GUICtrlCreateLabel('Selected Value', 500, 5, 150)
GUICtrlCreateLabel('Critical Threshold' & @CRLF & @CRLF & 'Value - Duration', 685, 5, 160, 40)
GUICtrlCreateLabel('Warning Threshold' & @CRLF & @CRLF & 'Value - Duration', 830, 5, 160)
GUICtrlCreateLabel('Where' & @CRLF & @CRLF & "Clause", 945, 5, 100, 40)
GUICtrlCreateLabel('Entity' & @CRLF & @CRLF & "Names(s)" , 1045, 5, 100, 40)
GUICtrlCreateLabel('Status', 1145, 5, 70)
GUICtrlCreateCheckbox('Select all', 1145, 25, 90)

; Create ListView
$cLV = GUICtrlCreateListView("", 10, 50, 1200, 400, $LVS_NOCOLUMNHEADER)
_GUICtrlListView_SetExtendedListViewStyle($cLV, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
GUICtrlSetBkColor($cLV, 0xC4C4C4)
_GUICtrlListView_AddColumn($cLV, "", 200)
_GUICtrlListView_AddColumn($cLV, "", 280)
_GUICtrlListView_AddColumn($cLV, "", 150)
_GUICtrlListView_AddColumn($cLV, "", 70)
_GUICtrlListView_AddColumn($cLV, "", 5)
_GUICtrlListView_AddColumn($cLV, "", 70)
_GUICtrlListView_AddColumn($cLV, "", 70)
_GUICtrlListView_AddColumn($cLV, "", 5)
_GUICtrlListView_AddColumn($cLV, "", 70)
_GUICtrlListView_AddColumn($cLV, "", 100)
_GUICtrlListView_AddColumn($cLV, "", 100)
_GUICtrlListView_AddColumn($cLV, "", 50)

; Initialise ListView 
$iLV_Index = _GUIListViewEx_Init($cLV)

GUISetState()

SplashTextOn("Loading", "Please be patient!")

For $i = 1 To 5 ; Set to a big number to test scrolling - but I assume you will be adding lines in much slower time

    $vData = "Link_" & StringFormat("%03i", $i) & "_1|Link_" & StringFormat("%03i", $i) & "_2|SelVal|Crit_1||Crit_2|Warn_1||Warn_2|Where|Entity|On"
    _GUIListViewEx_Insert($vData, False, True)

Next

SplashOff()

; Set cols 0 & 1 to run a user function when double clicked
_GUIListViewEx_SetEditStatus($iLV_Index, "0;1", 9, _Link)
; Set these columns to be editable when double clicked
_GUIListViewEx_SetEditStatus($iLV_Index, "2;3;5;6;8;9;10", 1, 0)
; Set column 11 to open a 2 item non-editable combo when double clicked
_GUIListViewEx_SetEditStatus($iLV_Index, "11", 2, "On|Off", 3)

; Get the UDF magic to work!
_GUIListViewEx_MsgRegister()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Allow editing of selected columns to occur - this can be expanded later to cover the $ES_NUMBER requirement
    _GUIListViewEx_EventMonitor()

WEnd

; The user function called when cols 0 & 1 are double clicked - you can do pretty much what you want in here
Func _Link($hLV_Handle, $iLV_Index, $iRow, $iCol)

    $sText = _GUICtrlListView_GetItemText($hLV_Handle, $iRow, $iCol)
    Switch $iCol
        Case 0
            MsgBox($MB_SYSTEMMODAL, "Link_1 Func", $sText)
        Case 1
            MsgBox($MB_SYSTEMMODAL, "Link_2 Func", $sText)
    EndSwitch

EndFunc

I hope it shows clearly what you can do with the UDF - and that the ListView is scrollable even with a large number of entries. Loading large numbers of lines takes a while at the moment because we are loading each line separately - in a more polished script we can speed this up considerably using other UDF functions.

As to why your 4000 control script was slow - you are asking AutoIt to do a lot when it has to manage so many controls. By using this ListView we are getting Windows itself to do all the "heavy lifting", which makes it much faster and smoother.

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

Hi @Melba23,

 

Thank you for the example. It looks good, I understood now what you suggested for the hyperlink that I want and why my initial script was slow :)
I will try to make all I need now using the GUIListView. I have only one concern, That the input box is visible after double-click on the item, but with the inputboxes it is directly editable. For the Status column, I think that it will be possible to make it edit all that are selected when click the right mouse button. I will just review all your examples again and again :)


Thank you agan!

Link to comment
Share on other sites

  • Moderators

MilenP,

Glad you like it.

Alas, you do need to double click to open the ListView elements for editing - but how often will you be editing them? As to the "Select all" checkbox, you can use the _GUIListViewEx_ChangeItem function to amend the element contents programmatically - so no problem to react to that request.

Do not hesitate to ask if you run into any problems getting the UDF to work as you wish.

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

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
 Share

  • Recently Browsing   0 members

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