nitekram

ComboBox updating items

34 posts in this topic

I have been trying to get this to work in my script...after creating an example script to ask a question, my original reason for writing the example was resolved. But I then found another issue that I am having trouble figuring out.

What I want is a combo list that is dynamic. I want the list to remove items that have been selected, and add items that have been changed. I have am still trying to resolve, but thought I would post it and see if I can get an answer.

; example of removing combo items, and updating the combo list for all remaining combos - including those that already have been asigned
#include <GUIConstantsEx.au3>
#include <array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0
; create the value of the combo list - using array to create values
For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
;_ArrayDisplay($aComboList)
Global $aTempArray = $aComboList
; convert the array into a string that can be used on a combo control
Global $sComboString = _ArrayToString($aComboList)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    If $x = 1 Then
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10)
        GUICtrlSetData(-1, $sComboString)
    Else
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10 + $iCount)
        GUICtrlSetData(-1, $sComboString)
    EndIf
    $iCount += 30
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            RemoveIndex($ahCombo[$x]) ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next

WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func RemoveIndex($hItem)
    ;_GUICtrlComboBox_GetList (not being used)
    Local $sTempComboValue = ''
    Local $sComboListTemp

    ConsoleWrite('Removing Item from Array - ' & GUICtrlRead($hItem) & @CRLF)
    For $x = UBound($aTempArray) - 1 To 0 Step -1
        If GUICtrlRead($hItem) = $aTempArray[$x] Then
            _ArrayDelete($aTempArray, $x)
            ;
            ExitLoop
        EndIf
    Next
    ;_ArrayDisplay($aTempArray)
    ; update all combos to the new string
    $sComboListTemp = _ArrayToString($aTempArray)
    For $x = 0 To UBound($ahCombo) - 1

        If GUICtrlRead($ahCombo[$x]) = '' Then
            ; if nothing has been selected, update with new combo list for future selection
            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sComboListTemp)

        ElseIf GUICtrlRead($ahCombo[$x]) <> '' Then
            ; if value already exist then keep value
            $sTempComboValue = GUICtrlRead($ahCombo[$x])
            ; set new combo list for this item

            For $y = UBound($aTempArray) - 1 To 0 Step -1
                If $aTempArray[$y] = '' Then
                    _ArrayDelete($aTempArray, $y)
                    $sComboListTemp = _ArrayToString($aTempArray)
                EndIf
            Next




; need a way to add the value back, if there was an item removed from selection for the calling control, and it is not being used elsewhere
#cs

            ;If Not StringInStr($sComboListTemp, $sTempComboValue) Then $sComboListTemp &= '|' & $sTempComboValue

            ; check for selected value being used, if it is not being used, then reinsert
            Local $sNewComboList = ''
            For $z = 1 To UBound($ahCombo) - 1
                If $z = UBound($ahCombo) - 1 Then ExitLoop
                $sNewComboList &= GUICtrlRead($ahCombo[$z]) & '|'
            Next
            Local $aNewComboList = StringSplit($sNewComboList, '|', 2)
            ;_ArrayDisplay($aNewComboList)

            ; Compare the strings
            $sNewComboList &= $sComboListTemp & $sComboString

            $aTempArray = _ArrayUnique($aNewComboList)
            _ArrayDisplay($aTempArray)
            _ArrayAdd($aTempArray, '')
            $sNewComboList = _ArrayToString($aTempArray)
#ce


            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sComboListTemp, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sNewComboList, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sNewComboList, $sTempComboValue)
        EndIf

    Next
EndFunc   ;==>RemoveIndex

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

nitekram,

That was a fun little problem. This seems to work for me - does it meet your requirements?

#include <GUIConstantsEx.au3>
#include <Array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0

For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
Global $sComboString = _ArrayToString($aComboList)
ConsoleWrite($sComboString & @CRLF)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    $ahCombo[$x] = GUICtrlCreateCombo('', 10, (30 * $x) - 20)
    GUICtrlSetData(-1, $sComboString)
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            _AlterCombos() ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func _AlterCombos()

    ; Capy the original full data string - add final "|" for matching
    $sNewString = $sComboString & "|"

    ; Now remove all currently selected items
    For $i = 1 To UBound($ahCombo) - 1
        If GUICtrlRead($ahCombo[$i]) Then
            $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($ahCombo[$i]) & "|", "|")
        EndIf
    Next
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($ahCombo) - 1
        $sCurrSel = GUICtrlRead($ahCombo[$i])
        $sThisString = $sNewString & "|" & $sCurrSel
        GUICtrlSetData($ahCombo[$i], $sThisString, $sCurrSel)
    Next

EndFunc   ;==>_AlterCombos

M23

Edited by Melba23
Amended code to cater for edge case

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

That worked as planned...guess I was trying to complicate it. Sometimes I would just like to watch the thought processes of the coders here, that know what they are doing.

 

Thanks again.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Okay, on the surface, it works, but not for my script. I tried to make an easy example, but it was two easy. I have more combo boxes, with different arrays, pulling from the same string. I might be able to figure this out, when I am less tired, but when working on this for a few hours before posting.

Here is my code...though I just started it - if anyone finds a way to make it smaller, please share.

 

Still trying to do the same thing...make is so once the item is picked, remove from string, and if it is available, add it back to the string.

; choir keeper
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $cDaysOff = '0x00ff00'
Global $aTime[23]
Global $aSunday[5][6], $aMonday[5][6], $aTuesday[5][6], $aWednesday[5][6], $aThursday[5][6], $aFriday[5][6], $aSaturday[5][6]
Global $sComboChores = ''
Global $aChores[23][3] = [ _
        ['Kitchen', False, $aTime[1]], _
        ['Master Bed Room', False, $aTime[2]], _
        ['Front Bed Room', False, $aTime[3]], _
        ['Back Bed Room', False, $aTime[4]], _
        ['Bathroom Full', False, $aTime[5]], _
        ['Bathroom Half', False, $aTime[6]], _
        ['Living Room', False, $aTime[7]], _
        ['Dining Bar', False, $aTime[8]], _
        ['Dining Porch', False, $aTime[9]], _
        ['Basement', False, $aTime[10]], _
        ['Garage', False, $aTime[11]], _
        ['Laundry Room', False, $aTime[12]], _
        ['Lawn (Cutting)', False, $aTime[13]], _
        ['Storage', False, $aTime[14]], _
        ['Porch', False, $aTime[15]], _
        ['Closed Porch', False, $aTime[16]], _
        ['Weed Pulling', False, $aTime[17]], _
        ['Misc1', False, $aTime[18]], _
        ['Misc2', False, $aTime[19]], _
        ['Misc3', False, $aTime[20]], _
        ['Misc4', False, $aTime[21]], _
        ['Misc5', False, $aTime[22]]]
;_ArrayDisplay($aChores)


; need
; timer - how long does it take
; choir name
; choir type - full, half, straighten
; week/day
; person name
; calendar
;
CreateSchedule()
; calandar
Func CreateSchedule()
    Local $hMainGui = GUICreate('Chore List', 1200, 525)
    Local $iCountDown = 70
    GUICtrlCreateLabel('Week One', 10, $iCountDown)
    ;
    GUICtrlCreateLabel('Week Two', 10, $iCountDown + 115)
    ;
    GUICtrlCreateLabel('Week Three', 10, $iCountDown + 230)
    ;
    GUICtrlCreateLabel('Week Four', 10, $iCountDown + 345)
    ;
    ;
    Local $iSpace = 155
    GUICtrlCreateLabel('Sunday', $iSpace, 10)
    GUICtrlCreateLabel('Monday', $iSpace * 2, 10)
    GUICtrlCreateLabel('Tuesday', $iSpace * 3, 10)
    GUICtrlCreateLabel('Wednesday', $iSpace * 4, 10)
    GUICtrlCreateLabel('Thursday', $iSpace * 5, 10)
    GUICtrlCreateLabel('Friday', $iSpace * 6, 10)
    GUICtrlCreateLabel('Saturday', $iSpace * 7, 10)
    $iCountDown = 20
    Local $iSideStep = 155

    ;$sComboChores = _ArrayToString($aChores)
    ;#cs
    ; create combo list
    For $x = 1 To UBound($aChores) - 1
        If $x = UBound($aChores) - 1 Then
            $sComboChores &= $aChores[$x][0]
        Else
            $sComboChores &= '|' & $aChores[$x][0];& '|'
        EndIf
    Next
    ;#ce
    ;
    ;
    Local $iJumpDown = 0, $iJumpOver = 0, $iWeek = 1
    For $x = 1 To UBound($aSunday) - 1
        $aSunday[$x][0] = 'Sunday Week' & $iWeek
        For $y = 1 To UBound($aSunday, 2) - 1
            $aSunday[$x][$y] = GUICtrlCreateCombo('', 110, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aMonday) - 1
        $aMonday[$x][0] = 'Monday Week' & $iWeek
        For $y = 1 To UBound($aMonday, 2) - 1
            $aMonday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aTuesday) - 1
        $aTuesday[$x][0] = 'Tuesday Week' & $iWeek
        For $y = 1 To UBound($aTuesday, 2) - 1
            $aTuesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 2, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aWednesday) - 1
        $aWednesday[$x][0] = 'Wednesday Week' & $iWeek
        For $y = 1 To UBound($aWednesday, 2) - 1
            $aWednesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 3, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aThursday) - 1
        $aThursday[$x][0] = 'Thursday Week' & $iWeek
        For $y = 1 To UBound($aThursday, 2) - 1
            $aThursday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 4, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aFriday) - 1
        $aFriday[$x][0] = 'Friday Week' & $iWeek
        For $y = 1 To UBound($aFriday, 2) - 1
            $aFriday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 5, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aSaturday) - 1
        $aSaturday[$x][0] = 'Saturday Week' & $iWeek
        For $y = 1 To UBound($aSaturday, 2) - 1
            $aSaturday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 6, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    GUISetState(@SW_SHOW, $hMainGui)

    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        For $x = 1 To UBound($aSunday) - 1
            For $y = 1 To UBound($aSunday, 2) - 1
                If $msg = $aSunday[$x][$y] Then
                    ;UpdateComboList($aSunday)
                    ;UpdateComboList($aMonday)
                    UpdateChoreList('','','')
                    ;UpdateChoreList(GUICtrlRead($aSunday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aSunday[$x][$y]))
                    ;UpdateChoreList($aSunday[$x][$y], GUICtrlRead($aSunday[$x][$y]), $sComboChores)
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aMonday) - 1
            For $y = 1 To UBound($aMonday, 2) - 1
                If $msg = $aMonday[$x][$y] Then
                    UpdateChoreList('','','')
                    ;UpdateComboList($aMonday)
                    ;UpdateChoreList($aMonday[$x][$y], GUICtrlRead($aMonday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aMonday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aTuesday) - 1
            For $y = 1 To UBound($aTuesday, 2) - 1
                If $msg = $aTuesday[$x][$y] Then
                    UpdateComboList($aTuesday)
                    ;UpdateChoreList($aTuesday[$x][$y], GUICtrlRead($aTuesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aTuesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aWednesday) - 1
            For $y = 1 To UBound($aWednesday, 2) - 1
                If $msg = $aWednesday[$x][$y] Then
                    UpdateComboList($aWednesday)
                    ;UpdateChoreList($aWednesday[$x][$y], GUICtrlRead($aWednesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aWednesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aThursday) - 1
            For $y = 1 To UBound($aThursday, 2) - 1
                If $msg = $aThursday[$x][$y] Then
                    UpdateComboList($aThursday)
                    ;UpdateChoreList($aThursday[$x][$y], GUICtrlRead($aThursday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aThursday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aFriday) - 1
            For $y = 1 To UBound($aFriday, 2) - 1
                If $msg = $aFriday[$x][$y] Then
                    UpdateComboList($aFriday)
                    ;UpdateChoreList($aFriday[$x][$y], GUICtrlRead($aFriday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aFriday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aSaturday) - 1
            For $y = 1 To UBound($aSaturday, 2) - 1
                If $msg = $aSaturday[$x][$y] Then
                    UpdateComboList($aSaturday)
                    ;UpdateChoreList($aSaturday[$x][$y], GUICtrlRead($aSaturday[$x][$y]), $sComboChores) ; MsgBox('', '', GUICtrlRead($aSaturday[$x][$y]))
                EndIf
            Next
        Next
    WEnd

    GUIDelete($hMainGui)

    ;_ArrayDisplay($aSunday)
EndFunc   ;==>CreateSchedule
;
Func UpdateChoreList($hControl, $sDeleteFromList, $sComboChorestemp)
    #cs
    Local $aTempCombo = StringSplit($sComboChorestemp, '|', 2)
    ;_ArrayDisplay($aTempCombo)
    ;_ArrayDisplay($aTempCombo)
    For $x = UBound($aTempCombo) - 1 To 0 Step -1
        If $sDeleteFromList = $aTempCombo[$x] Then
            MsgBox('', '$sDeleteFromList', $sDeleteFromList)
            _ArrayDelete($aTempCombo, $x)
            _ArrayDelete($aChores, $x)
            ExitLoop
        EndIf
    Next
    ;Return

    $sComboChores = ''
    $sComboChores = _ArrayToString($aTempCombo)
    ;GUICtrlSetData($hControl, '')
    ;GUICtrlSetData($hControl, $sComboChores, $sDeleteFromList)
    #ce
    ;UpdateComboList($hControl)

    UpdateComboList($aSunday)
    UpdateComboList($aMonday)
    UpdateComboList($aTuesday)
    UpdateComboList($aWednesday)
    UpdateComboList($aThursday)
    UpdateComboList($aFriday)
    UpdateComboList($aSaturday)



EndFunc   ;==>UpdateChoreList
;

;



Func UpdateComboList($aArray)
    ;MsgBox('','$sComboChores',$sComboChores)
    ;
    ; Capy the original full data string - add final "|" for matching
    Local $sNewString = $sComboChores & "|"


    ;Local $sTempValue = GUICtrlRead($hControl), $sAnother = ''

    ; Now remove all currently selected items
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            If GUICtrlRead($aArray[$i][$j]) Then
                $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($aArray[$i][$j]) & "|", "|")
                ConsoleWrite($sNewString)
            EndIf
            ConsoleWrite(@CRLF)
        Next
    Next

    ;MsgBox('','', $sNewString)
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            $sCurrSel = GUICtrlRead($aArray[$i][$j])
            $sThisString = $sNewString & "|" & $sCurrSel
            ;GUICtrlSetData($aSunday[$i][$j], '')
            GUICtrlSetData($aArray[$i][$j], $sThisString, $sCurrSel)
        Next
    Next
$sComboChores = $sThisString
    #cs
        For $x = 1 To UBound($aSunday) - 1
        For $y = 1 To UBound($aSunday, 2) - 1
        If GUICtrlRead($aSunday[$x][$y]) = '' Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Or GUICtrlRead($hControl) <> '' Then
        If GUICtrlRead($hControl) = GUICtrlRead($aSunday[$x][$y]) Then

        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Then
        ConsoleWrite('1 ' & @CRLF)
        $sAnother = GUICtrlRead($aSunday[$x][$y])
        ;
        ;$sComboChores = $sAnother & '|' & $sComboChores
        ;
        GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sAnother & '|' & $sComboChores, $sAnother)
        EndIf
        Else

        EndIf
        Next
        Next

        If $sTempValue = GUICtrlRead($aSunday[$x][$y]) Then
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        ;GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        EndIf
        EndIf

    #ce
    #cs
        For $x = 1 To UBound($aMonday) - 1
        For $y = 1 To UBound($aMonday, 2) - 1
        If GUICtrlRead($aMonday[$x][$y]) = '' Then
        GUICtrlSetData($aMonday[$x][$y], '')
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aTuesday) - 1
        For $y = 1 To UBound($aTuesday, 2) - 1
        If GUICtrlRead($aTuesday[$x][$y]) = '' Then
        GUICtrlSetData($aTuesday[$x][$y], '')
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aWednesday) - 1
        For $y = 1 To UBound($aWednesday, 2) - 1
        If GUICtrlRead($aWednesday[$x][$y]) = '' Then
        GUICtrlSetData($aWednesday[$x][$y], '')
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aThursday) - 1
        For $y = 1 To UBound($aThursday, 2) - 1
        If GUICtrlRead($aThursday[$x][$y]) = '' Then
        GUICtrlSetData($aThursday[$x][$y], '')
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aFriday) - 1
        For $y = 1 To UBound($aFriday, 2) - 1
        If GUICtrlRead($aFriday[$x][$y]) = '' Then
        GUICtrlSetData($aFriday[$x][$y], '')
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aSaturday) - 1
        For $y = 1 To UBound($aSaturday, 2) - 1
        If GUICtrlRead($aSaturday[$x][$y]) = '' Then
        GUICtrlSetData($aSaturday[$x][$y], '')
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
    #ce
EndFunc   ;==>UpdateComboList

Thanks again for any help

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

Just how do you want this to work? Obviously the "5-a-day" choices need to be unique, but what about as you proceed through the week? Is it each chore once a week only or can they appear several times? And presumably each week is an entirely separate entity?

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

@M23

All great questions...I will have to think about that, before I ask for your help. I do not want to waste your time, if I later change my mind later - so better make sure what I want first.

I will answer this question tomorrow - thanks for making me think it out.

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

better make sure what I want first

A very good idea! Now if only other posters would adopt the same principle.

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

#8 ·  Posted (edited)

Okay, I had a long drive home...I now know what I want - but not sure if possible (may be a bid tedious)

I want the function I call to have a parameter (1, 2, 4) ONE would be each week, TWO would divide the 4 weeks into two sections, and FOUR would be over all 4 weeks.

EDIT

If possible can you comment it, so I can follow the process of your brain?

 

EDIT 2

If the array scheme that I have now makes it harder, I am not worried if it needs to be changed to make it easier. If you need it changed, just let me know, and I will make the change, and repost it.

 

EDIT 3

In fact, I am sure you want me to change it, as I can see it being easier to divide everything into weeks???

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

Good job it was a rainy afternoon! That was a really fun problem - and I think I have a solution.  Play around with this and see if it does what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>

;         Chore,            interval (1, 2, 4 weeks),   Count in week 1,2,3,4
Global $aChoresBase[][] = [ _
        ['Kitchen',         1,                          0, 0, 0, 0], _
        ['Master Bed Room', 1,                          0, 0, 0, 0], _
        ['Front Bed Room',  2,                          0, 0, 0, 0], _
        ['Back Bed Room',   2,                          0, 0, 0, 0], _
        ['Bathroom Full',   1,                          0, 0, 0, 0], _
        ['Bathroom Half',   2,                          0, 0, 0, 0], _
        ['Living Room',     1,                          0, 0, 0, 0], _
        ['Dining Bar',      1,                          0, 0, 0, 0], _
        ['Dining Porch',    2,                          0, 0, 0, 0], _
        ['Basement',        4,                          0, 0, 0, 0], _
        ['Garage',          4,                          0, 0, 0, 0], _
        ['Laundry Room',    2,                          0, 0, 0, 0], _
        ['Lawn (Cutting)',  2,                          0, 0, 0, 0], _
        ['Storage',         4,                          0, 0, 0, 0], _
        ['Porch',           2,                          0, 0, 0, 0], _
        ['Closed Porch',    2,                          0, 0, 0, 0], _
        ['Weed Pulling',    2,                          0, 0, 0, 0], _
        ['Misc1',           4,                          0, 0, 0, 0], _
        ['Misc2',           4,                          0, 0, 0, 0], _
        ['Misc3',           4,                          0, 0, 0, 0], _
        ['Misc4',           4,                          0, 0, 0, 0], _
        ['Misc5',           4,                          0, 0, 0, 0]]

_ArrayDisplay($aChoresBase, "Original", Default, 8) ; Display only

; Create combo list
$sChoreListBase = ""
For $i = 0 To UBound($aChoresBase) - 1
    $sChoreListBase &= "|" & $aChoresBase[$i][0]
Next

Global $cCombo_Start

CreateSchedule()

Func CreateSchedule()

    Local $hMainGui = GUICreate('Chore List', 1200, 540)

    ; Create labels
    Local $iWeekSpacing = 125, $iWeekOffset = 90
    For $i = 1 To 4
        GUICtrlCreateLabel('Week ' & $i, 10, ($i * $iWeekSpacing) - $iWeekOffset)
    Next
    Local $iDaySpacing = 155, $iDayOffset = 45
    Local $aDay[8] = ["", 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
    For $i = 1 To 7
        GUICtrlCreateLabel($aDay[$i], $iDaySpacing * ($i) - $iDayOffset, 10, 125, 20, $SS_CENTER)
    Next

    ; Create combos
    $cCombo_Start = GUICtrlCreateDummy() + 1 ; ControlID of first combo
    Local $iComboOffset = 21, $iChoresPerDay = 5
    For $i = 1 To 4 ; Weeks
        $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
        For $j = 1 To 7 ; Days
            $iX = ($iDaySpacing * $j) - $iDayOffset
            For $k = 0 To $iChoresPerDay - 1 ; Chores
                $iY = $iY_Base + ($iComboOffset * $k)
                GUICtrlCreateCombo("", $iX, $iY, 125, 20)
                GUICtrlSetData(-1, $sChoreListBase)
            Next
        Next
    Next
    $cCombo_End = GUICtrlCreateDummy() - 1 ; ControlID of last combo

    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $cCombo_Start To $cCombo_End ; Combo actioned
                _Update_Combos()
        EndSwitch
    WEnd


EndFunc

Func _Update_Combos()

    ; Read data from all combos into new blank chores array
    Local $aChores = $aChoresBase
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo setting - ControlID calculated
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            If $sSel Then
                ; Find index of selected chore in the array
                $iIndex = _ArraySearch($aChores, $sSel)
                ; Set for correct week
                $aChores[$iIndex][$i + 2] += 1
            EndIf
        Next
    Next
    _ArrayDisplay($aChores, "Up To Date", Default, 8) ; Display only

    ; Copy base combo list - one for each week
    Local $aChoreList[5] = ["", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|"]

    ; Now run through chores and decide if interval criteria met
    For $i = 0 To UBound($aChores) - 1
        ; Check required interval
        Switch $aChores[$i][1]
            Case 1 ; Once per week
                For $j = 1 To 4
                    ; So if chosen in this week
                    If $aChores[$i][$j + 1] Then
                        ; Remove from the list for this week only
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from List " & $j & @CRLF)
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    EndIf
                Next
            Case 2 ; Once every 2 weeks
                ; Split into 2 x 2-week sections
                For $k = 0 To 2 Step 2
                    ; If chosen in this section
                    $iCount = 0
                    For $j = 1 To 2
                        $iCount += $aChores[$i][$j + $k + 1]
                    Next
                    If $iCount Then
                        $sLists = ( ($k) ? ("3 & 4") : ("1 & 2") )
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)
                        ; Remove from both lists for this section
                        For $j = 1 + $k To 2 + $k
                            $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                        Next
                    EndIf
                Next
            Case 4 ; Once every 4 weeks
                ; If chosen
                $iCount = 0
                For $j = 1 To 4
                    $iCount += $aChores[$i][$j + 1]
                Next
                If $iCount Then
                    ; Remove from all lists
                    ConsoleWrite("Removing " & $aChores[$i][0] & " from ALL Lists" & @CRLF)
                    For $j = 1 To 4
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    Next
                EndIf
        EndSwitch
    Next
    _ArrayDisplay($aChoreList, "Combo Data Lists", Default, 8) ; Display only

    ; Now fill combos
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            ; Get data string for this week
            $sData = StringTrimRight($aChoreList[$i + 1], 1)
            ; Add current selection if required
            If $sSel Then
                $sData &= "|" & $sSel
            EndIf
            ; Load combo
            GUICtrlSetData($cCombo_Start + $j + ($i * 35), $sData, $sSel)
        Next
    Next

EndFunc

Please do ask if anything is unclear - although I have tried to comment liberally,it is not always easy to make things as clear as they appear to the original coder.

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

#10 ·  Posted (edited)

First off - I am amazed at how short it is. I know it will work, but I am having an issue running it.

ERROR: (132,23) : ERROR: syntax error (illegal character)

$sLists = (($k) ? ("3 & 4") :("1 & 2"))

I do not know this code, and I tried to do a search in the help file, but that was pointless - can you tell me what this is called?

 

EDIT

I commented out these two line and am starting to play with it - I will be back soon

;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
;ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

 

EDIT 2

I actually got that code to work, changed it to - but would still like to learn this new syntax

If $k = 3 Or $k = 4 Then
                            $sLists = "3 & 4"
                        Else
                            $sLists = "1 & 2"
                        EndIf
                        ;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

it is an example of the ternary operator that was introduced in v3.3.10.0 (23rd December, 2013) - you are obviously a good couple of releases behind me!

Just replace that line by these and all will work as expected:

$sLists = "1 & 2"
If $k Then $sLists = "3 & 4"

And that line is only for display purposes anyway.

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

Okay...I am amazed. This is far more than I wanted, for your thought processes is at a higher level than mine. I never even thought of making each choir like that, where each one will have its own schedule.

I want to thank you...I will come back with questions on how you did something/things. Hope you do not mind me picking your brain?

Got to get some sleep now. Working graveyard is not fun, but at least I have AutoIt to keep me company.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

Hope you do not mind me picking your brain?

Of course not - ask away.

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

#14 ·  Posted (edited)

Okay, starting with the questions...

First can you explain the thought process in getting the format of the labels and combo boxes - maybe pseudo code of what you are doing. I see what you did, but not sure how you got there - if that makes any sense. I mean you see mine, and how long it took me to copy and paste, and copy and paste, and you get the idea.

Edited by nitekram
spelling

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Second...I have not used the Dummy control for quite some time, and only once. What is it and why are you using it? Is that like using an array, without using an array, to be able to get the control IDs handle?


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

Creating grids of controls

If you ever have to create any controls that are in a regular pattern (the labels and combos in this script are a perfect example) then it is nearly always quicker (and certainly shorter) to do so in a loop and to use an algorithm (short formula) to determine the coordinates of each one as they are created. As the combos are the most complex, let us start with them.

Obviously we need to decide some of the constant values before we begin - the spacing between each column and row, how many in each column and row, etc. Then we need to decide the order in which we want to create them to ease subsequent coding - in this case we were looking to differentiate the weeks, so creating the weeks in succession seemed a good way to go, so we start with the week loop and determine the vertical position of the first combo of each block. The formula is very simple (and used in all 3 loops) - the spacing increases by the same amount for each pass and the offset makes sure the first pass is at the correct value:

For $i = 1 To 4 ; Weeks
  $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset ; These values were already defined when we created the week labels

Now we will be creating 7 blocks of combos, one for each day so we need to create these in succession making another loop inside the first - inside which we determine the horizontal position of each block:

For $j = 1 To 7 ; Days
   $iX = ($iDaySpacing * $j) - $iDayOffset ; Again, these values were determined when we created the day labels.

Finally we need to create a combos in the block - each one will be slightly lower than its predecessor, so we use a final loop to calculate the vertical position based on the initial value we determined in the outer loop above:

For $k = 0 To $iChoresPerDay - 1 ; Chores
    $iY = $iY_Base + ($iComboOffset * $k)

Now we have the X & Y coordinates for each combo and can create it in the correct place.  Here is a short script to show the values inside the loops and the order in which the controls are created (plus their ControlIDs in parentheses - (see below why this is of interest):

#include <GUIConstantsEx.au3>

Local $hMainGui = GUICreate('Chore List', 1200, 540)

GUISetState()

; The constants required
Local $iWeekSpacing = 125, $iWeekOffset = 90
Local $iDaySpacing = 155, $iDayOffset = 45
Local $iComboOffset = 21, $iChoresPerDay = 5

; The 3 loops
For $i = 1 To 4 ; Weeks
    $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
    For $j = 1 To 7 ; Days
        $iX = ($iDaySpacing * $j) - $iDayOffset
        For $k = 0 To $iChoresPerDay - 1 ; Chores
            $iY = $iY_Base + ($iComboOffset * $k)
            $cCID = GUICtrlCreateLabel("", $iX, $iY, 125, 20)
            GUICtrlSetData($cCID, $i & " - " & $j & " - " & $k & " > (" & $cCID & ")")
            GUICtrlSetBkColor($cCID, 0xFFCCCC)
            Sleep(100)
        Next
    Next
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Dummy Controls

Dummies can be very useful - in this script we use them to determine the values of the first and last combos created as the dummies obviously have the ControlIDs just before/after the first/last combo created. This is a trick which only works because AutoIt normally assigns the ControlIDs in numerical succession (it can fail to do this if controls have previously been created and deleted, but that is not the case here) which enables us to loop through the controls one by one. Remember that I mentioned above we wanted to  divide the controls into weeks in the outer loop? As a result the ControlIDs run as you can see in the example above: n to n+34 in the first week, n+35 to n+69 in the second, and so on - and it is now easy to loop through each week's set of combos when deciding whether a certain value has been set.

I hope that is sufficiently clear - please ask again if not.

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

M23,

I may be going back to some older scripts and doing a redesign...I think this part that you wrote, should some how make it the help file or something, as it would help others as well. As far as learning this...I guess it is the algorithm, that is stumping me. How do you go about creating/solving it, and knowing when to use it?

And I again, thank you for your time, explaining this layout to me...I do believe that example that you wrote is just, well beautiful.

I now have to get some good questions about the refresh of the combos - after trying to figure it out. I will be back lol

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

The algorithm is in fact very simple - increase a parameter each time you go through a loop - but the trick is doing it in 2/3D as we do here. You can use it whenever you have to create controls in some form of pattern (it is particularly well-suited to grids) where the spacing can be calculated by a simple formula. As to the actual formula - I try and work it out in paper first and then run a simulation script to test that the values I have chosen actually work. And of course, you will nearly always need some form of constant to adjust for the initial position - even Einstein needed one of those, so I have no problem doing the same.

Standing by for the "combo refresh" questions!

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

M23,

I think I will stay away from learning gravity, until I am older, as I will be even closer to the ground - Einstein created a constant in space, so I guess I can start making things up, and only crap my pants, if someone asks me to prove it lol

Okay, I see these offsets are coming in handy, as you also are using them to get past the array indexes that are not part of the loop - I am learning more everyday!

I got all the way to the second case (split into 2 weeks) statement - with understanding, but I am lost...there is a lot going on. May we start with the $iCount, and how it comes into play, I mean my mind is hurting trying to figure it out - LET ALONE how would I begin to even think this way and write it.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

nitekram,

Let us take the whole function (which is called each time a combo is actioned) and break it down:

First we create a copy of the $aChores array so we can see what is and is not set this time around.

Then we read all the combos - see how we can read each week in turn by running through in sections of 35. Then if there is a value already set, we find the element of the $aChores array that matches the selected chore and set the correct "week" element (which we can easily calculate from the week number). Now we will have the array filled with all the currently selected chores and the weeks in which they have been selected.

We then create a $aChoreList array with each week being given a full list of the chores to carry out - we need to have 4 as some chores are weekly and might still be selectable in other weeks. The next task is to remove from each list those chores which are already being carried out - so first we need to check how often the chores need to be done: once a week means remove from that week only; every 2 weeks means removes from a 2 week block if already done; while every 4 weeks means remove from all of  lists. We run through each chore in turn and Switch depending on the frequency set (1, 2, 4).

- If 1 (each week) then we look at each week in turn to see if that chore is already selected - the "week" element of the $aChores array will have been set if it is - and if so, remove that chore from that week's list in the $aChoreList array.

- If 2 (every 2 weeks) then we need to look at 2-week blocks (1-2 & 3-4) - and we use 2 loops to do this. The outer loop runs twice with values of 0 and 2, while the inner runs twice from 1 to 2. Adding them means we get the values 1, 2, 3, 4 which nicely matches the week numbering. Inside the 2 loops we check both of the "week" elements of the $aChores array for the 2-week block and if the chore is selected, remove it from both of the lists for those weeks in the $aChoreList array.

- If every 4 weeks then the problem becomes a little simpler - we need a single loop to check each of the "week" elements of the $aChores array and if the chore is set, remove it from all of the lists in the $aChoreList array.

We now have the $aChoreList array filled with 4 lists of the remaining chores for each week. We run yet another loop to fill each week's combos with their respective list - not forgetting to add back the currently displayed value and set it as the default.

And Robert is your mother's brother! Does that make the script clearer?

As to the thought processes I used to develop this - it is mostly a question of logic.  I will try and reconstruct what I did.

You wanted to have 1,2,4 week intervals which forces us to store the required interval, so why not in the same array as the chores themselves?  Using this same array to store the chores already selected in each week is therefore a sensible choice as it keeps everything together.

The next step follows on from something I learnt a long time ago and which I pass on with pleasure. When faced with a long repetitive task (such as which combos need changing) humans tend to look for the changes so as to minimize the number of times things need to be done.  However, computers are usually faster running the whole list of tasks as that means there are fewer conditional statements to run for each item - and they are usually so fast that humans do not notice the passage of time required in any event. So when a combo is actioned we do not look at that particular combo, we just read the whole set and recalculate and reset the combo contents for the entire GUI.  It seems illogical, but believe me it is usually by far the best and fastest way to go about things.

The chore removal logic is the same as I developed for your first query - just expanded to cater for the fact that we have 4 separate lists for the 4 weeks. As I have mentioned previously, choosing the right data structure and loop elements initially makes subsequent coding easier - this is I am afraid mostly (painfully gained) experience and there is no magic formula. But I would stress that it often pays to go back and completely restructure your initial data storage and various loop parameters if by so doing you can make the intensive parts of the script easier to code - the time spent is well worth it in terms of clarity of code and speed of execution.

So there you have it - any more questions?

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

  • Similar Content

    • Xandy
      By Xandy
      I have a bunch of SDL_Surfaces loaded into memory.  I want to list them in a ComboBox.
      Using this code, I can load images to the combobox from file but not from existing SDL_Surface memory
      CODE ISN"T MEANT TO RUN
      ; Create combobox pic list example $aControl[$iControl_id][$eControl_data] = _GUICtrlComboBoxEx_Create($gui, $data_value, $data_x, $data_y, $data_w, $data_h, $CBS_DROPDOWNLIST) ; Image List for ComboboxEx Local $hImage = _GUIImageList_Create($gTile_w, $gTile_h, 6) ; Fill hImage with SDL_Surfaces stored in memory: aNPC_surf[scale][type][way][frame] For $i = 0 To 1 ; This works but only from file: ;_GUIImageList_AddBitmap($hImage, $gFolder_graphics & $gaWorld_info[$player.iWorld_cur][$eWi_filename] & "Tiles\" & $i & ".bmp") ; I've broken up a sprite sheet and want to insert into combobox from memory ;_GUIImageList_Add($hImage, $aNPC_surf[1][1][1][$i]) _GUIImageList_Add($hImage, _GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]), True) ;_GDIPlus_BitmapCreateFromMemory($aNPC_surf[1][1][1][$i]) ; Add the index number to combobox item _GUICtrlComboBoxEx_AddString($aControl[$eNPC_iPic_type][$eControl_data], $i, $i, $i) Next ; Set hImage list to combobox control _GUICtrlComboBoxEx_SetImageList($aControl[$eNPC_iPic_type][$eControl_data], $hImage) Anyone know if I can convert from SDL_Surface to hBitmap?  Maybe I'm doing something else wrong.
       
      I've seen hBitmap converted to SDL_Surface but I don't really understand it yet: 
       
      My full script can be found here:
       
    • odaylton
      By odaylton
      I even understand that the Handle generated by _WinAPI_LoadCursor is not an Icon but how to display the image in the Combobox
      Here is the listing and please tell me how to make the current user current cursor image uncertainty
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo Local $idListview, $hImage Local $sWow64 = "" Local $Pasta="C:\WINDOWS\Cursors\3dgarro.cur" $hGUI = GUICreate("ImageList Mouse Icons", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100) $idListview = GUICtrlCreateListView("", 2, 104, 394, 200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 16) ;teste _GUIImageList_AddIcon($hImage, $Pasta) ;<<<<<<<<<<<<<<<<<<<<<this $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0,$IDC_HAND));32649 ; Hand cursor _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<<<<<<<< erro for $i=1 to 15 $hIcon= _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $i));<<<<<<<<<<<<<<<<< _GUIImageList_AddIcon($hImage, $hIcon);<<<<<<<<<<<< Next _GUIImageList_AddIcon($hImage, $Pasta) _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items $a=StringSplit("testeIcone|HAND|APPSTARTING|ARROW|CROSS|HELP|IBEAM|ICON|NO|SIZE|SIZEALL|SIZENESW|SIZENS|SIZENWSE|SIZEWE|UPARROW|WAIT|testefim","|") For $i=1 to $a[0] _GUICtrlListView_AddItem($idListview, $a[$i], $i-1) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $i-1) Next ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Note that only the initial image is uncertain because it comes from a file
      And the one that would be the last enters as the second
      And the background is black how to transform into transparent
      imagem de cursor.bmp
    • Ian_Mac
      By Ian_Mac
      hello, i just wanted to ask if how........
       I have a gui combo box with a list and i wanted it to remember the last item that i selected, that when i close the gui and then open the gui again, my last selected item will be automatically show in the combobox as selected item already.
      thank you in advance.
    • argumentum
      By argumentum
      #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Array.au3> #include <WinAPITheme.au3> #include <GDIPlus.au3> #Region GUICtrlComboSetColors UDF Global $g__aWM_CTLCOLORLISTBOX[1][16] = [[0, 0, 0]] ; init. the Global array ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors ; Description ...: Change the colors and position/size of a ComboBox ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iBgColor = Default] [, $iFgColor = Default] [, $iExtendLeft = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iBgColor - Background RGB color ; - or "-1" to use prior color declared ; - or to remove a control by ControlID, "-2" ; - or to remove a control by ArrayIndex, "-3" ; $iFgColor - Foreground RGB color ; - or "-1" to use prior color declared ; - or "-2" to use sytem color and leave theme default ; $iExtendLeft - pixels to extend the dropdown list ; - or "-1" to use prior width declared ; - or "1" auto size, extending left ( see Remarks/AutoSize ) ; - or "2" auto size, extending right ( see Remarks/AutoSize ) ; Return values .: Success - index position in the array ; Failure - 0 ; @error - 1 : Control handle = 0 ; - 2 : GetComboBoxInfo failed ; - 3 : Control for removal not found ; @extended - 2 : Success on Control removal ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; AutoSize...: use the pertinent parameters from GUICtrlComboSetColors_SetAutoSize() ; minus the CtrlID as semicolon separated to initialize. Ex: "2;Arial;8.5;0" ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors($idCombo = 0, $iBgColor = Default, $iFgColor = Default, $iExtendLeft = Default) If Not $idCombo Then Return SetError(1, 0, 0) Local $n, $tInfo, $i = 0 If $iBgColor = -2 Or $iBgColor = -3 Then Local $m For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If ($g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo And $iBgColor = -2) Or ($g__aWM_CTLCOLORLISTBOX[$n][9] = $idCombo And $iBgColor = -3) Then _ArrayDelete($g__aWM_CTLCOLORLISTBOX, $n) $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(0, 2, $n) EndIf Next Return SetError(3, 0, 0) EndIf For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then $i = $n ExitLoop EndIf Next If Not $i Then $g__aWM_CTLCOLORLISTBOX[0][0] += 1 $i = $g__aWM_CTLCOLORLISTBOX[0][0] ; If $i >= UBound($g__aWM_CTLCOLORLISTBOX) Then ReDim $g__aWM_CTLCOLORLISTBOX[$i + 1][16] ; add extra "slots" EndIf EndIf Local $sStr = GUICtrlRead($idCombo) Local $iSetWindowTheme = 1 If $iBgColor = Default And $iFgColor = Default Then $iSetWindowTheme = 0 If $iBgColor = Default Then $iBgColor = _WinAPI_GetSysColor($COLOR_WINDOW) If $iFgColor = Default Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) If $iBgColor = -1 Then $iBgColor = $g__aWM_CTLCOLORLISTBOX[$i][10] If $iFgColor = -1 Then $iFgColor = $g__aWM_CTLCOLORLISTBOX[$i][11] $g__aWM_CTLCOLORLISTBOX[$i][11] = $iFgColor $g__aWM_CTLCOLORLISTBOX[$i][10] = $iBgColor If $iExtendLeft = Default Then $iExtendLeft = 0 $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf If $iExtendLeft = -1 Then $iExtendLeft = $g__aWM_CTLCOLORLISTBOX[$i][8] ElseIf Int($iExtendLeft) = 1 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 1 ElseIf Int($iExtendLeft) = 2 Then $g__aWM_CTLCOLORLISTBOX[$i][12] = 2 Else $g__aWM_CTLCOLORLISTBOX[$i][12] = 0 EndIf $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($iExtendLeft) $g__aWM_CTLCOLORLISTBOX[$i][0] = $idCombo $g__aWM_CTLCOLORLISTBOX[$i][1] = GUICtrlGetHandle($idCombo) $g__aWM_CTLCOLORLISTBOX[$i][13] = "Arial" ; default $sFont $g__aWM_CTLCOLORLISTBOX[$i][14] = 8.5 ; default $fSize $g__aWM_CTLCOLORLISTBOX[$i][15] = 0 ; default $iStyle If $g__aWM_CTLCOLORLISTBOX[$i][12] Then $f = StringSplit($iExtendLeft, ";") If UBound($f) > 1 Then $g__aWM_CTLCOLORLISTBOX[$i][8] = Int($f[1]) If UBound($f) > 2 Then $g__aWM_CTLCOLORLISTBOX[$i][13] = $f[2] If UBound($f) > 3 Then $g__aWM_CTLCOLORLISTBOX[$i][14] = Int($f[3]) If UBound($f) > 4 Then $g__aWM_CTLCOLORLISTBOX[$i][15] = Int($f[4]) $t = TimerInit() GUICtrlComboSetColors_SetAutoSize(Int("-" & $i), $g__aWM_CTLCOLORLISTBOX[$i][12], $g__aWM_CTLCOLORLISTBOX[$i][13], $g__aWM_CTLCOLORLISTBOX[$i][14], $g__aWM_CTLCOLORLISTBOX[$i][15]) ConsoleWrite(TimerDiff($t) & @CRLF) EndIf If _GUICtrlComboBox_GetComboBoxInfo($idCombo, $tInfo) Then If $iSetWindowTheme Then If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], "", "") If $g__aWM_CTLCOLORLISTBOX[$i][11] <> -2 Then GUICtrlSetColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iFgColor) GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], $iBgColor) Else GUICtrlSetBkColor($g__aWM_CTLCOLORLISTBOX[$i][0], _WinAPI_GetSysColor($COLOR_HOTLIGHT)) _WinAPI_SetWindowTheme($g__aWM_CTLCOLORLISTBOX[$i][1], 0, 0) EndIf $g__aWM_CTLCOLORLISTBOX[$i][2] = DllStructGetData($tInfo, "hCombo") $g__aWM_CTLCOLORLISTBOX[$i][3] = DllStructGetData($tInfo, "hEdit") $g__aWM_CTLCOLORLISTBOX[$i][4] = DllStructGetData($tInfo, "hList") ; this is what is colored Else $g__aWM_CTLCOLORLISTBOX[0][0] -= 1 Return SetError(2, 0, 0) EndIf If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) $g__aWM_CTLCOLORLISTBOX[$i][5] = 0 ; holder for "_WinAPI_CreateSolidBrush()" return value $g__aWM_CTLCOLORLISTBOX[$i][6] = BitOR(BitAND($iBgColor, 0x00FF00), BitShift(BitAND($iBgColor, 0x0000FF), -16), BitShift(BitAND($iBgColor, 0xFF0000), 16)) If $g__aWM_CTLCOLORLISTBOX[$i][11] = -2 Then $iFgColor = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) $g__aWM_CTLCOLORLISTBOX[$i][7] = BitOR(BitAND($iFgColor, 0x00FF00), BitShift(BitAND($iFgColor, 0x0000FF), -16), BitShift(BitAND($iFgColor, 0xFF0000), 16)) If Not $g__aWM_CTLCOLORLISTBOX[0][1] Then If $g__aWM_CTLCOLORLISTBOX[$i][4] Then $g__aWM_CTLCOLORLISTBOX[0][1] = GUIRegisterMsg($WM_CTLCOLORLISTBOX, "UDF_WM_CTLCOLORLISTBOX") If $g__aWM_CTLCOLORLISTBOX[0][1] Then OnAutoItExitRegister("OnAutoItExit_UDF_WM_CTLCOLORLISTBOX") EndIf EndIf $g__aWM_CTLCOLORLISTBOX[0][2] += 1 $g__aWM_CTLCOLORLISTBOX[$i][9] = $g__aWM_CTLCOLORLISTBOX[0][2] ; internal ID $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() ; to use in UDF_WM_CTLCOLORLISTBOX() $g__aWM_CTLCOLORLISTBOX[0][4] = 0 ; to use in UDF_WM_CTLCOLORLISTBOX() If $sStr Then GUICtrlSetData($idCombo, $sStr) Return SetError(0, 0, $g__aWM_CTLCOLORLISTBOX[0][2]) EndFunc ;==>GUICtrlComboSetColors Func UDF_WM_CTLCOLORLISTBOX($hWnd, $Msg, $wParam, $lParam) ConsoleWrite('+ Func UDF_WM_CTLCOLORLISTBOX(' & $hWnd & ', ' & $Msg & ', ' & $wParam & ', ' & $lParam & ')' & @CRLF) For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$i][4] = $lParam Then If TimerDiff($g__aWM_CTLCOLORLISTBOX[0][3]) > 500 Or $g__aWM_CTLCOLORLISTBOX[0][4] <> $lParam Then If $g__aWM_CTLCOLORLISTBOX[$i][12] Then GUICtrlComboSetColors_SetAutoSize("-" & $i) EndIf $g__aWM_CTLCOLORLISTBOX[0][3] = TimerInit() $g__aWM_CTLCOLORLISTBOX[0][4] = $lParam If $g__aWM_CTLCOLORLISTBOX[$i][8] > 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0] - $g__aWM_CTLCOLORLISTBOX[$i][8], $aWPos[1] + $aWPos[3], $aWPos[2] + $g__aWM_CTLCOLORLISTBOX[$i][8]) ElseIf $g__aWM_CTLCOLORLISTBOX[$i][8] < 0 Then Local $aWPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$i][2]) WinMove($lParam, "", $aWPos[0], $aWPos[1] + $aWPos[3], $aWPos[2] - $g__aWM_CTLCOLORLISTBOX[$i][8]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][7] >= 0 Then _WinAPI_SetTextColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][7]) EndIf If $g__aWM_CTLCOLORLISTBOX[$i][6] >= 0 Then _WinAPI_SetBkColor($wParam, $g__aWM_CTLCOLORLISTBOX[$i][6]) If Not $g__aWM_CTLCOLORLISTBOX[$i][5] Then $g__aWM_CTLCOLORLISTBOX[$i][5] = _WinAPI_CreateSolidBrush($g__aWM_CTLCOLORLISTBOX[$i][6]) Return $g__aWM_CTLCOLORLISTBOX[$i][5] EndIf Return 0 EndIf Next EndFunc ;==>UDF_WM_CTLCOLORLISTBOX ; #FUNCTION# ==================================================================================================================== ; Name...........: GUICtrlComboSetColors_SetAutoSize ; Description ...: Set autosize for a ComboBox initialized in GUICtrlComboSetColors() ; Syntax.........: GUICtrlComboSetColors ( $idCombo [, $iExtendLeft = Default] [, $sFont = Default] [, $fSize = Default] [, $iStyle = Default] ) ; Parameters ....: $idCombo - GUICtrlCreateCombo() ControlID / [ ArrayIndex ] ; $iExtendLeft - 1 = Left, 2 = Right, 0 = disable auto-sizing ; $sFont - Font name ; $fSize - Font size ; $iStyle - Font style ; Return values .: Success - widthest string in pixels ; Failure - -1 ; @error - look at the comments in the function ; Author ........: argumentum ; Modified.......: v0.0.0.5 ; Remarks .......: this UDF is in its a work in progress, will expand if needed. ; Related .......: GUICtrlComboSetColors() ; Link ..........: https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-bgcolor/ ; Example .......: Yes, at the end of the file ; =============================================================================================================================== Func GUICtrlComboSetColors_SetAutoSize($idCombo, $iExtendLeft = Default, $sFont = Default, $fSize = Default, $iStyle = Default) ConsoleWrite('+ Func GUICtrlComboSetColors_AutoSizeSet("' & $idCombo & '", "' & $iExtendLeft & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '")' & @CRLF) $idCombo = Int($idCombo) ; just in case the value is a string Local $n, $iArrayIndex = 0, $iCtrl = 0 If $idCombo > 0 Then For $n = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If $g__aWM_CTLCOLORLISTBOX[$n][0] = $idCombo Then ; the expected value, is the ControlID $iArrayIndex = $n ExitLoop EndIf Next Return SetError(4, 0, -1) ; $iArrayIndex not found ElseIf $idCombo < 0 Then ; the expected value, is a negative of array's index .. $iArrayIndex = Int(StringTrimLeft(StringStripWS($idCombo, 8), 1)) ; .. so now is a positive value .. If $iArrayIndex < 1 Then Return SetError(3, 0, -1) ; .. else, error .. If $iArrayIndex > $g__aWM_CTLCOLORLISTBOX[0][0] Then Return SetError(2, 0, -1) ; .. as long as is not greater than expected Else Return SetError(1, 0, -1) ; could not find a usable value EndIf Switch $iExtendLeft Case 0, 1, 2 $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = $iExtendLeft EndSwitch Local $aCtrlPos = WinGetPos($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][1]) If UBound($aCtrlPos) <> 4 Then Return SetError(5, 0, -1) ; could not get a usable value Local $sString = StringReplace(_GUICtrlComboBox_GetList($g__aWM_CTLCOLORLISTBOX[$iArrayIndex][0]), "|", @CRLF) Local $aStrWidth = _GDIPlus_MeasureString($sString, $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][13], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][14], $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][15]) If UBound($aStrWidth) <> 2 Then Return SetError(6, 0, -1) ; could not get a usable value If $aStrWidth[0] < $aCtrlPos[2] Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = 0 Else $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = $aStrWidth[0] - $aCtrlPos[2] If $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][12] = 2 Then $g__aWM_CTLCOLORLISTBOX[$iArrayIndex][8] = Int("-" & $aStrWidth[0] - $aCtrlPos[2]) EndIf Return $aStrWidth[0] EndFunc ;==>GUICtrlComboSetColors_SetAutoSize Func _GDIPlus_MeasureString($sString, $sFont = "Arial", $fSize = 12, $iStyle = 0, $bRound = True) ConsoleWrite('Func _GDIPlus_MeasureString("' & $sString & '", "' & $sFont & '", "' & $fSize & '", "' & $iStyle & '", "' & $bRound & '")' & @CRLF) ; original code @ https://www.autoitscript.com/forum/topic/150736-gdi-wrapping-text/?do=findComment&comment=1077210 If Not $__g_iGDIPRef Then _GDIPlus_Startup() ; added by argumentum for this UDF's implementation ( AutoIt v3.3.14 ) due to the way the function is written ;~ Func _GDIPlus_Startup($sGDIPDLL = Default, $bRetDllHandle = False) ;~ $__g_iGDIPRef += 1 <-- I believe this aspect should be coded differently in "GDIPlus.au3" ;~ If $__g_iGDIPRef > 1 Then Return True Local $aSize[2] Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) If Not $hFamily Then Return SetError(1, 0, $aSize) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) $aSize[0] = $bRound ? Round($aInfo[0].Width, 0) : $aInfo[0].Width $aSize[1] = $bRound ? Round($aInfo[0].Height, 0) : $aInfo[0].Height _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return $aSize EndFunc ;==>_GDIPlus_MeasureString Func OnAutoItExit_UDF_WM_CTLCOLORLISTBOX() For $i = 1 To $g__aWM_CTLCOLORLISTBOX[0][0] If Int($g__aWM_CTLCOLORLISTBOX[$i][5]) Then _WinAPI_DeleteObject($g__aWM_CTLCOLORLISTBOX[$i][5]) Next If $__g_iGDIPRef Then _GDIPlus_Shutdown() EndFunc ;==>OnAutoItExit_UDF_WM_CTLCOLORLISTBOX #EndRegion GUICtrlComboSetColors UDF Example() Func Example() ; Create GUI GUICreate("ComboBox Set DROPDOWNLIST BgColor", 640, 300) Local $a_idCombo[7] = [6] $a_idCombo[1] = GUICtrlCreateCombo("", 2, 2, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[1], 0xEEEEEE, -2, Default) Example_FillTheCombo($a_idCombo[1]) GUICtrlCreateLabel("<<< change BG color, default theme && size ", 400, 4, 396, 296) $a_idCombo[2] = GUICtrlCreateCombo("", 2, 32, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[2], 0x0000FF, 0xFFFF00, 0) Example_FillTheCombo($a_idCombo[2]) GUICtrlCreateLabel("<<< change colors", 400, 34, 396, 296) $a_idCombo[3] = GUICtrlCreateCombo("", 2, 62, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[3], 0xdddddd, Default, 100) Example_FillTheCombo($a_idCombo[3]) GUICtrlCreateLabel("<<< change BG color, resize 100px. left", 400, 64, 396, 296) $a_idCombo[4] = GUICtrlCreateCombo("", 2, 92, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[4], Default, 0x0000FF, -100) Example_FillTheCombo($a_idCombo[4]) GUICtrlCreateLabel("<<< change FG color, resize 100px. right", 400, 94, 396, 296) $a_idCombo[5] = GUICtrlCreateCombo("", 2, 122, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlComboSetColors($a_idCombo[5], 0x00FFFF, 0x0000FF, 1) Example_FillTheCombo($a_idCombo[5]) GUICtrlCreateLabel("<<< change colors, resize auto left", 400, 124, 396, 296) $a_idCombo[6] = GUICtrlCreateCombo("", 2, 152, 390, 296, BitOR($CBS_DROPDOWNLIST, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($a_idCombo[6], 10, 400, 0, "Courier New") GUICtrlComboSetColors($a_idCombo[6], Default, Default, "2;Courier New;10") Example_FillTheCombo($a_idCombo[6]) GUICtrlCreateLabel("<<< default colors, resize auto right", 400, 154, 396, 296) Local $bttnArrayShow = GUICtrlCreateButton("Show array", 2, 296 - 27, 75, 25) Local $bttnStrMore = GUICtrlCreateButton("Longer str.", 102, 296 - 27, 75, 25) Local $idLorem = GUICtrlCreateLabel("", 195, 296 - 27, 50, 25) Local $bttnStrLess = GUICtrlCreateButton("Shorter str.", 252, 296 - 27, 75, 25) GUISetState(@SW_SHOW) WinActivate("ComboBox Set DROPDOWNLIST BgColor") ;~ Sleep(3500) ; you can reassign colors, size, or restore default ;~ GUICtrlComboSetColors($idCombo5, Default, Default, 300) ; this resets the Control back to default and changes $iExtendLeft ;~ GUICtrlComboSetColors($idCombo5, 0x0000FF, 0x00FFFF, -1) ; this changes the colors and keeps $iExtendLeft as it was ;~ GUICtrlComboSetColors($idCombo5, -1, -1, 300) ; using "-1" will keep the existing colors ;~ ; so in this case, only the $iExtendLeft is declared ;~ Example_FillTheCombo($idCombo5) ;~ Sleep(500) ; after removal, it will not repaint "hList", but then again, you're deleteing the control ;~ GUICtrlComboSetColors($idColors, -3) ;~ GUICtrlDelete($idCombo2) Local $iLorem = 5, $sLorem = "" Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Return Case $bttnArrayShow _ArrayDisplay($g__aWM_CTLCOLORLISTBOX, "$g__aWM_CTLCOLORLISTBOX") Case $bttnStrMore $iLorem += 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) Case $bttnStrLess $iLorem -= 5 Example_LoremStr($iLorem, $sLorem, $a_idCombo, $idLorem) EndSwitch WEnd EndFunc ;==>Example Func Example_FillTheCombo(ByRef $idComboCtrl) GUICtrlSetData($idComboCtrl, "") _GUICtrlComboBox_AddString($idComboCtrl, "something") _GUICtrlComboBox_AddString($idComboCtrl, "something else") _GUICtrlComboBox_AddString($idComboCtrl, "blah, blah, blah, blah") _GUICtrlComboBox_AddString($idComboCtrl, "Lorem will change") Local $a = _GUICtrlComboBox_GetListArray($idComboCtrl) GUICtrlSetData($idComboCtrl, $a[1]) EndFunc ;==>Example_FillTheCombo Func Example_LoremStr(ByRef $iLorem, ByRef $sLorem, ByRef $a_idCombo, ByRef $idLorem) Local Static $s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." $s &= " Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat." Local Static $i = 5, $a = StringSplit($s, " ") If $iLorem < 1 Then $iLorem = 1 If $iLorem > $a[0] Then $iLorem = $a[0] Local $x, $iLastEntry $sLorem = "" GUICtrlSetData($idLorem, $iLorem & ' words') For $x = 1 To $iLorem $sLorem &= $a[$x] & " " Next For $x = 1 To $a_idCombo[0] $iLastEntry = _GUICtrlComboBox_GetCount($a_idCombo[$x]) - 1 _GUICtrlComboBox_DeleteString($a_idCombo[$x], $iLastEntry) _GUICtrlComboBox_AddString($a_idCombo[$x], $sLorem) Next EndFunc ;==>Example_LoremStr new in v0.0.0.5: auto size the dropdown.
    • kcvinu
      By kcvinu
      Hi all,
      How can i get notified when user clicks on a combo box's edit area ? This is my code so far. 
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <ComboConstants.au3> #include <ListBoxConstants.au3> Global $btn ; creates a window Global $Window_0 = GUICreate("My Window", 800, 500, -1, -1, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) $btn = GUICtrlCreateButton("Click Me", 50, 50, 120, 50) Global $cmb = GUICtrlCreateCombo("Sample", 50, 150, 300, 50) GUICtrlSetFont(-1,12,400) Global $lstbx = GUICtrlCreateList("FirstItem", 400,50, 200, 300) GUICtrlSetFont(-1,12,400) GUIRegisterMsg($WM_COMMAND, "MyEventCallback") GUIRegisterMsg($WM_SIZE, "MyEventCallback") GUIRegisterMsg($WM_NOTIFY, "NotifyManager") GUISetState(@SW_SHOW) GUICtrlSetData($cmb, "Item 2|Item 3", "Item 2") GUICtrlSetData($lstbx, "Apple|Orange|Pineapple|Grape|Lemon") Do $Event = GUIGetMsg( ) Until $Event = $GUI_EVENT_CLOSE Func MyEventCallback($hwnd, $message, $wParam, $lParam) Select Case $message = $WM_COMMAND ;---------------------------------------------------------------- If LoWord($wParam) = $cmb Then ; if control id is combox's Then Local $Notification = HiWord($wParam) Select Case $Notification = $CBN_DROPDOWN ; here we check the notification code. ConsoleWrite("$CBN_DROPDOWN Worked " & @MIN & ":" & @SEC & @CRLF) Case $Notification = $CBN_EDITCHANGE ; here we check the notification code. ConsoleWrite("$CBN_EDITCHANGE Worked " & @MIN & ":" & @SEC & @CRLF) ; **** Here i want add the code for combo box clicking. EndSelect ;--------------------------------------------------------------------- ElseIf LoWord($wParam) = $lstbx Then Local $Notification = HiWord($wParam) Select Case $Notification = $LBN_SELCHANGE ConsoleWrite("$LBN_SELCHANGE" & @CRLF) EndSelect EndIf ;------------------------------------------------------------------ Case $message = $WM_SIZE EndSelect Return $GUI_RUNDEFMSG EndFunc ;==>ProGUI_EventCallback Func NotifyManager($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ;Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If DllStructGetData($tagNMHDR, 3) = $NM_LDOWN Then ConsoleWrite("Notify Worked" & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc Func LoWord($Variable) Return BitAND($Variable, 0xFFFF) EndFunc Func HiWord($Variable) Return BitShift($Variable, 16) EndFunc