Jump to content

[SOLVED] How to detect Combo value change


ALTIN
 Share

Recommended Posts

I think my problem is simple but Im not finding how to solve it.

I have a Combo and I want to get its current value upon when I select it (upon it changes when selected), I mean without adding any button or other control to do a GUICtrlRead($hCombo)

This is what I basically have:

#include <GUIConstantsEx.au3>

Example()
Func Example()
    Local $msg
    GUICreate("My GUI combo", 300, 150)

    $hCombo = GUICtrlCreateCombo("item1", 10, 10)
    GUICtrlSetData(-1, "item2|item3", "item3")
    GUISetState()

    While 1
        $msg = GUIGetMsg()      
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
            
        ToolTip(GUICtrlRead($hCombo))
        
    WEnd
EndFunc

I also tried something with _GUICtrlComboBox_GetDroppedState() but could not do it.

Any suggestion please?

Edited by ALTIN
Link to comment
Share on other sites

Oh yet..... sorry again ;)

I want to get the current value after I select it on combo when it is not dropped down but this seems to return the value even if combo is dropped down and i hover the mouse over it...

So I guess it does basically the same thing I had before...

P.S.: Sorry, I read the previous post from mobile and thought it was solved but now that I try in editor, I see it did not...

Any other idea?

Edited by ALTIN
Link to comment
Share on other sites

  • Moderators

ALTIN,

I think does what you want - it waits until you have closed the combo before reading the value: ;)

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

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

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($hCombo, "|1|2|3|4")

GUISetState()

$sCurrCombo = ""

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    $sComboSel = GUICtrlRead($hCombo)
    If $sComboSel <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then
        MsgBox(0, "Selection", $sComboSel)
        $sCurrCombo = $sComboSel
    EndIf
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

I think does what you want - it waits until you have closed the combo before reading the value: ;)

Oh I see now you both are just right and I know I may look weird and stupid today ;) I made such a big alarm for a beginner problem.

Anyway Thankx Cameronsdad, Thanks Melba23, you both solved it.

I guess I need a long break to stop hanging in simple things :)

Link to comment
Share on other sites

  • Moderators

ALTIN,

I could not see why you thought cameronsdad's example was not working - so I decided I would show you another way - although his version is simpler! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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