Jump to content
Sign in to follow this  
Tippex

Too Slow ComboBox

Recommended Posts

Tippex

My program is being slowed down by comboboxes. Is there a faster alternative please:

For example, on a typical spec PC the combo boxes in my code clip below take ages to create. I'm aware that an early GUISetState() allows them to be seen being created one by one but it shows where the problem is. I wondered whether there was some other technique such as a rotating wheel that would be quicker please?

#Include <GuiComboBox.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Dim $mainwindow, $Typ1, $Typ2, $Typ3, $Typ4, $Typ5, $Typ6, $Typ7, $Typ8, $Typ9, $Typ10

$mainwindow = GUICreate("Slow Combo", 200, 400, -1, -1, $WS_THICKFRAME + $WS_MINIMIZEBOX)

GUISetState()

$Typ1 = _GUICtrlComboBox_Create($mainwindow, "", 32, 40 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ1, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ1)

_GUICtrlComboBox_AddString($Typ1, "3D")

_GUICtrlComboBox_AddString($Typ1, "DW")

_GUICtrlComboBox_AddString($Typ1, "MU")

_GUICtrlComboBox_AddString($Typ1, "SU")

_GUICtrlComboBox_AddString($Typ1, "32")

_GUICtrlComboBox_AddString($Typ1, "EO")

_GUICtrlComboBox_AddString($Typ1, "CO")

_GUICtrlComboBox_AddString($Typ1, "3G")

_GUICtrlComboBox_AddString($Typ1, "3S")

_GUICtrlComboBox_AddString($Typ1, "FE")

_GUICtrlComboBox_AddString($Typ1, "DM")

_GUICtrlComboBox_AddString($Typ1, "EL")

_GUICtrlComboBox_AddString($Typ1, "FB")

_GUICtrlComboBox_AddString($Typ1, "NC")

_GUICtrlComboBox_EndUpdate($Typ1)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ2 = _GUICtrlComboBox_Create($mainwindow, "", 32, 60 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ2, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ2)

_GUICtrlComboBox_AddString($Typ2, "3D")

_GUICtrlComboBox_AddString($Typ2, "DW")

_GUICtrlComboBox_AddString($Typ2, "MU")

_GUICtrlComboBox_AddString($Typ2, "SU")

_GUICtrlComboBox_AddString($Typ2, "32")

_GUICtrlComboBox_AddString($Typ2, "EO")

_GUICtrlComboBox_AddString($Typ2, "CO")

_GUICtrlComboBox_AddString($Typ2, "3G")

_GUICtrlComboBox_AddString($Typ2, "3S")

_GUICtrlComboBox_AddString($Typ2, "FE")

_GUICtrlComboBox_AddString($Typ2, "DM")

_GUICtrlComboBox_AddString($Typ2, "EL")

_GUICtrlComboBox_AddString($Typ2, "FB")

_GUICtrlComboBox_AddString($Typ2, "NC")

_GUICtrlComboBox_EndUpdate($Typ2)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ3 = _GUICtrlComboBox_Create($mainwindow, "", 32, 80 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ3, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ3)

_GUICtrlComboBox_AddString($Typ3, "3D")

_GUICtrlComboBox_AddString($Typ3, "DW")

_GUICtrlComboBox_AddString($Typ3, "MU")

_GUICtrlComboBox_AddString($Typ3, "SU")

_GUICtrlComboBox_AddString($Typ3, "32")

_GUICtrlComboBox_AddString($Typ3, "EO")

_GUICtrlComboBox_AddString($Typ3, "CO")

_GUICtrlComboBox_AddString($Typ3, "3G")

_GUICtrlComboBox_AddString($Typ3, "3S")

_GUICtrlComboBox_AddString($Typ3, "FE")

_GUICtrlComboBox_AddString($Typ3, "DM")

_GUICtrlComboBox_AddString($Typ3, "EL")

_GUICtrlComboBox_AddString($Typ3, "FB")

_GUICtrlComboBox_AddString($Typ3, "NC")

_GUICtrlComboBox_EndUpdate($Typ3)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ4 = _GUICtrlComboBox_Create($mainwindow, "", 32, 100 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ4, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ4)

_GUICtrlComboBox_AddString($Typ4, "3D")

_GUICtrlComboBox_AddString($Typ4, "DW")

_GUICtrlComboBox_AddString($Typ4, "MU")

_GUICtrlComboBox_AddString($Typ4, "SU")

_GUICtrlComboBox_AddString($Typ4, "32")

_GUICtrlComboBox_AddString($Typ4, "EO")

_GUICtrlComboBox_AddString($Typ4, "CO")

_GUICtrlComboBox_AddString($Typ4, "3G")

_GUICtrlComboBox_AddString($Typ4, "3S")

_GUICtrlComboBox_AddString($Typ4, "FE")

_GUICtrlComboBox_AddString($Typ4, "DM")

_GUICtrlComboBox_AddString($Typ4, "EL")

_GUICtrlComboBox_AddString($Typ4, "FB")

_GUICtrlComboBox_AddString($Typ4, "NC")

_GUICtrlComboBox_EndUpdate($Typ4)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ5 = _GUICtrlComboBox_Create($mainwindow, "", 32, 120 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ5, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ5)

_GUICtrlComboBox_AddString($Typ5, "3D")

_GUICtrlComboBox_AddString($Typ5, "DW")

_GUICtrlComboBox_AddString($Typ5, "MU")

_GUICtrlComboBox_AddString($Typ5, "SU")

_GUICtrlComboBox_AddString($Typ5, "32")

_GUICtrlComboBox_AddString($Typ5, "EO")

_GUICtrlComboBox_AddString($Typ5, "CO")

_GUICtrlComboBox_AddString($Typ5, "3G")

_GUICtrlComboBox_AddString($Typ5, "3S")

_GUICtrlComboBox_AddString($Typ5, "FE")

_GUICtrlComboBox_AddString($Typ5, "DM")

_GUICtrlComboBox_AddString($Typ5, "EL")

_GUICtrlComboBox_AddString($Typ5, "FB")

_GUICtrlComboBox_AddString($Typ5, "NC")

_GUICtrlComboBox_EndUpdate($Typ5)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ6 = _GUICtrlComboBox_Create($mainwindow, "", 32, 140 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ6, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ6)

_GUICtrlComboBox_AddString($Typ6, "3D")

_GUICtrlComboBox_AddString($Typ6, "DW")

_GUICtrlComboBox_AddString($Typ6, "MU")

_GUICtrlComboBox_AddString($Typ6, "SU")

_GUICtrlComboBox_AddString($Typ6, "32")

_GUICtrlComboBox_AddString($Typ6, "EO")

_GUICtrlComboBox_AddString($Typ6, "CO")

_GUICtrlComboBox_AddString($Typ6, "3G")

_GUICtrlComboBox_AddString($Typ6, "3S")

_GUICtrlComboBox_AddString($Typ6, "FE")

_GUICtrlComboBox_AddString($Typ6, "DM")

_GUICtrlComboBox_AddString($Typ6, "EL")

_GUICtrlComboBox_AddString($Typ6, "FB")

_GUICtrlComboBox_AddString($Typ6, "NC")

_GUICtrlComboBox_EndUpdate($Typ6)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ7 = _GUICtrlComboBox_Create($mainwindow, "", 32, 160 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ7, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ7)

_GUICtrlComboBox_AddString($Typ7, "3D")

_GUICtrlComboBox_AddString($Typ7, "DW")

_GUICtrlComboBox_AddString($Typ7, "MU")

_GUICtrlComboBox_AddString($Typ7, "SU")

_GUICtrlComboBox_AddString($Typ7, "32")

_GUICtrlComboBox_AddString($Typ7, "EO")

_GUICtrlComboBox_AddString($Typ7, "CO")

_GUICtrlComboBox_AddString($Typ7, "3G")

_GUICtrlComboBox_AddString($Typ7, "3S")

_GUICtrlComboBox_AddString($Typ7, "FE")

_GUICtrlComboBox_AddString($Typ7, "DM")

_GUICtrlComboBox_AddString($Typ7, "EL")

_GUICtrlComboBox_AddString($Typ7, "FB")

_GUICtrlComboBox_AddString($Typ7, "NC")

_GUICtrlComboBox_EndUpdate($Typ7)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ8 = _GUICtrlComboBox_Create($mainwindow, "", 32, 180 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ8, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ8)

_GUICtrlComboBox_AddString($Typ8, "3D")

_GUICtrlComboBox_AddString($Typ8, "DW")

_GUICtrlComboBox_AddString($Typ8, "MU")

_GUICtrlComboBox_AddString($Typ8, "SU")

_GUICtrlComboBox_AddString($Typ8, "32")

_GUICtrlComboBox_AddString($Typ8, "EO")

_GUICtrlComboBox_AddString($Typ8, "CO")

_GUICtrlComboBox_AddString($Typ8, "3G")

_GUICtrlComboBox_AddString($Typ8, "3S")

_GUICtrlComboBox_AddString($Typ8, "FE")

_GUICtrlComboBox_AddString($Typ8, "DM")

_GUICtrlComboBox_AddString($Typ8, "EL")

_GUICtrlComboBox_AddString($Typ8, "FB")

_GUICtrlComboBox_AddString($Typ8, "NC")

_GUICtrlComboBox_EndUpdate($Typ8)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ9 = _GUICtrlComboBox_Create($mainwindow, "", 32, 200 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ9, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ9)

_GUICtrlComboBox_AddString($Typ9, "3D")

_GUICtrlComboBox_AddString($Typ9, "DW")

_GUICtrlComboBox_AddString($Typ9, "MU")

_GUICtrlComboBox_AddString($Typ9, "SU")

_GUICtrlComboBox_AddString($Typ9, "32")

_GUICtrlComboBox_AddString($Typ9, "EO")

_GUICtrlComboBox_AddString($Typ9, "CO")

_GUICtrlComboBox_AddString($Typ9, "3G")

_GUICtrlComboBox_AddString($Typ9, "3S")

_GUICtrlComboBox_AddString($Typ9, "FE")

_GUICtrlComboBox_AddString($Typ9, "DM")

_GUICtrlComboBox_AddString($Typ9, "EL")

_GUICtrlComboBox_AddString($Typ9, "FB")

_GUICtrlComboBox_AddString($Typ9, "NC")

_GUICtrlComboBox_EndUpdate($Typ9)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Typ10 = _GUICtrlComboBox_Create($mainwindow, "", 32, 220 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

; _GUICtrlComboBox_InitStorage($Typ10, 15, 4)

_GUICtrlComboBox_BeginUpdate($Typ10)

_GUICtrlComboBox_AddString($Typ10, "3D")

_GUICtrlComboBox_AddString($Typ10, "DW")

_GUICtrlComboBox_AddString($Typ10, "MU")

_GUICtrlComboBox_AddString($Typ10, "SU")

_GUICtrlComboBox_AddString($Typ10, "32")

_GUICtrlComboBox_AddString($Typ10, "EO")

_GUICtrlComboBox_AddString($Typ10, "CO")

_GUICtrlComboBox_AddString($Typ10, "3G")

_GUICtrlComboBox_AddString($Typ10, "3S")

_GUICtrlComboBox_AddString($Typ10, "FE")

_GUICtrlComboBox_AddString($Typ10, "DM")

_GUICtrlComboBox_AddString($Typ10, "EL")

_GUICtrlComboBox_AddString($Typ10, "FB")

_GUICtrlComboBox_AddString($Typ10, "NC")

_GUICtrlComboBox_EndUpdate($Typ10)

GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUISetState()

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites
Mat

What is it these boxes are for? If we knew that then we could help with a better design...

My instinct is to say that the dropdown is merely a list control, so if the contents is the same for each list then you create the control once and handle the dropdown messages manually. Unless you know the winapi well, and this is important enough to you that you want to do a lot of research and run the risk that it won't work.

Next idea is create all the controls, then add the items. That way the controls are updated straight away, so the user does not see any lag. Then the stuff that can't be seen (the items) can be added afterwards.

Make sure the combobox does not have the CBS_SORT style (not sure if it's enabled by default or not) as that will slow down insertion.

Finally, I'd compare the UDF combobox against the internal AutoIt managed one (GUICtrlCreate...). Who knows, maybe it's faster.

GUICtrlSetResizing won't work for custom controls, so those statements you make at the end of each one are redundant. Won't (shouldn't) affect performance but they are not going to work as intended.

Share this post


Link to post
Share on other sites
Tippex

Thank you.

The boxes are actually part of a form that a sizeable user community completes so as to request me to send out product data, and towards the end of each entry they select the type they need (eg. "3D" being an electronic model, "DW" an electronic drawing). I chose the combobox style as it shows the kind of types the user is aware of but does allow more advance users to manually enter a type that they believe has been missed of the list if they need to.

At first I did try the internal combobox and found the UDF one far quicker.

CBS_SORT style isn't an intended default according to the documentation:

Default: $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL

Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE

As each combo drop down list is the same, I can see a saving in having a single floating compo type selection to fill an active (one of ten) input box but haven't a clue on how to go about it.

I wondered how to make my own simple combobox selection that would be quicker. Any ideas?

Share this post


Link to post
Share on other sites
Tippex

Thank you. Moving the "add the items" code has helped a little.

Surprisingly it would seem that the control creation is where the majority of the slow down is occuring which is noticable when there's a number of comboboxes.

Even without data, the comboboxes seem to be appears slowly on the screen.

#Include <GuiComboBox.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Dim $mainwindow, $Typ1, $Typ2, $Typ3, $Typ4, $Typ5, $Typ6, $Typ7, $Typ8, $Typ9, $Typ10

$mainwindow = GUICreate("Slow Combo", 200, 400, -1, -1, $WS_THICKFRAME + $WS_MINIMIZEBOX)

GUISetState()

$Typ1 = _GUICtrlComboBox_Create($mainwindow, "", 32, 40 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ2 = _GUICtrlComboBox_Create($mainwindow, "", 32, 60 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ3 = _GUICtrlComboBox_Create($mainwindow, "", 32, 80 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ4 = _GUICtrlComboBox_Create($mainwindow, "", 32, 100 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ5 = _GUICtrlComboBox_Create($mainwindow, "", 32, 120 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ6 = _GUICtrlComboBox_Create($mainwindow, "", 32, 140 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ7 = _GUICtrlComboBox_Create($mainwindow, "", 32, 160 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ8 = _GUICtrlComboBox_Create($mainwindow, "", 32, 180 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ9 = _GUICtrlComboBox_Create($mainwindow, "", 32, 200 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

$Typ10 = _GUICtrlComboBox_Create($mainwindow, "", 32, 220 + 30, 42, 100, BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE))

GUISetState()

Do

Until GUIGetMsg() = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites
Spiff59

They seem to popup pretty quickly for me. It doesn't seem a delay anyone would consider excessive.

You could always just delete the first GUISetState() and have the gui popup after the combos have been created.

Chalk the time up to program initialization.

You do probably have enough duplicated BitOR() statements in there to justify an extra variable:

$combo_style = BitOR($CBS_DROPDOWN, $WS_VSCROLL, $WS_TABSTOP, $CBS_UPPERCASE)
$Typ1 = _GUICtrlComboBox_Create($mainwindow, "", 32, 40 + 30, 42, 100, $combo_style)
...
...

but since 95% of your processing time is within the combo create statements themselves, it's not going to save you a lot.

Edited by Spiff59

Share this post


Link to post
Share on other sites
Melba23

Tippex,

Have you thought of using PopUp menus? :graduated:

This script shows you how you might do it - either right or left click on the"menu" arrow to the right of each input: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiMenu.au3>

; Global variables
Global $aInput[10], $aLabel[10], $iIndex

Global $aMenu[14][2] = [ _
        ["3D", 1000], _
        ["DW", 1001], _
        ["MU", 1002], _
        ["SU", 1003], _
        ["33", 1004], _
        ["EO", 1005], _
        ["CO", 1006], _
        ["3G", 1007], _
        ["3S", 1008], _
        ["FE", 1009], _
        ["DM", 1010], _
        ["EL", 1011], _
        ["FB", 1012], _
        ["NC", 1013]]

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

; Create inputs
For $i = 0 To 9
    $aInput[$i] = GUICtrlCreateInput("", 30, 50 + (20 * $i), 50, 20)
Next

; Create labels - important that they are in IMMEDIATE SUCCESSION
For $i = 0 To 9
    $aLabel[$i] = GUICtrlCreateLabel("6", 80, 50 + (20 * $i), 20, 20)
    GUICtrlSetFont(-1, 10, 200, 0, "Webdings")
Next

GUISetState()

; Register messages
GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; If you only want left clicks delete this line
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1

    ; look for events
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ; Left clicks on labels are actioned here - delete this Case if you only want right clicks
        Case $aLabel[0] To $aLabel[9]
            _Menu($iMsg - $aLabel[0])
    EndSwitch

WEnd

Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) ; If you only want left clicks delete this function

    #forceref $hWnd, $iMsg, $lParam

    ; Right clicks on labels are actioned here
    For $i = 0 To 9
        If $wParam = GUICtrlGetHandle($aLabel[$i]) Then
            _Menu($i)
            ExitLoop
        EndIf
    Next

EndFunc

Func _Menu($i)

    ; Set the index of the label clicked
    $iIndex = $i
    ; Create the popup menu
    $hMenu = _GUICtrlMenu_CreatePopup()
    For $i = 0 To 13
        _GUICtrlMenu_InsertMenuItem($hMenu, $i, $aMenu[$i][0], $aMenu[$i][1])
    Next
    ; Wait for the selection
    _GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
    _GUICtrlMenu_DestroyMenu($hMenu)

EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $lParam

    ; Depending on the selection, set the associated input to the value chosen
    For $i = 0 To 13
        If $wParam = $i + 1000 Then
            GUICtrlSetData($aInput[$iIndex], $aMenu[$i][0])
            ExitLoop
        EndIf
    Next

EndFunc   ;==>WM_COMMAND

If you only want right or left clicks to action the menu just delete the sections indicated. ;)

Any use? ;)

M23

P.S. If you are wondering why the PopUp menus are not on the inputs themselves - that type of control already has a system context menu and will not accept another. So we need the labels. :D

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
rover

Greetings Melba

Nice menu idea, certainly faster

@Tippex

This example optimizes the combobox creation time and adds data after the controls are created.

The native combobox is faster than the UDF.

Increasing the priority of your process while creating controls will decrease the initialization time.

Setting the minimum visible items to a number lower than the default of 30 increases the speed of combobox creation.

Edit: corrected OP adding styles with + instead of BitOr()

Edit: removed $GUI_SS_DEFAULT_COMBO, restored original combo styles, added set CB_SETMINVISIBLE message

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
;temporarily set a higher priority while creating controls
ProcessSetPriority(@AutoItPID, 3);3 above normal - no performance increase above this
Global $iMinimum = 8 ;minimum visible items in dropdown list
Global $sString = "3D|DW|MU|SU|32|EO|CO|3G|3S|FE|DM|EL|FB|NC"
Global $iStyles = BitOR($CBS_DROPDOWN, $WS_VSCROLL, $CBS_UPPERCASE) ;WS_TABSTOP is a forced style
Global $mainwindow, $Typ[11] = [10];use an array instead of individual variables
$mainwindow = GUICreate("Not So Slow Combo", 200, 400, -1, -1, BitOR($WS_THICKFRAME, $WS_MINIMIZEBOX))
;GUISetState()
 
;create comboboxes without data
For $i = 1 To $Typ[0]
    $Typ[$i] = GUICtrlCreateCombo("", 32, (70 + (($i - 1) * 20)), 42, 100, $iStyles)
    ;$Typ[$i-1] = _GUICtrlComboBox_Create($mainwindow, $sString, 32, (70 + (($i - 1) * 20)), 42, 100, $iStyles)
    ;setting to value lower than 30 decreases combobox creation time
    GUICtrlSendMsg($Typ[$i], $CB_SETMINVISIBLE, $iMinimum, 0) ;set minimum visible items in dropdown list
    ;GUICtrlSetData(-1, $sString) ;still fast if data added here and minimum visible items set lower than 30
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
Next
GUISetState()
;120 ms - Native GUICtrlCreateCombo() + GUICtrlSetData() + GUICtrlSetResizing()
;196 ms - UDF _GUICtrlComboBox_Create()
;34  ms - Native GUICtrlCreateCombo() - data set after all controls created and shown
 
;optionally add data to comboboxes after all controls are created
For $i = 1 To $Typ[0]
    GUICtrlSetData($Typ[$i], $sString)
Next
ProcessSetPriority(@AutoItPID, 2);normal - restore normal priority
 
 
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites
Tippex

:graduated: Belated thanks!

Both are excellent solutions.

I'm going for the amazing ProcessSetPriority which should speed up my other control creations too!

Share this post


Link to post
Share on other sites
Melba23

Tippex,

I had forgotten all about this! You certainly take your time when coding! :D

But be very careful with ProcessSetPriority - never go above 3 (Above Normal) or you end up in all sorts of problems. :o

I really would recommend not using it if at all possible. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


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
Sign in to follow this  

×