Jump to content

Popup Listbox and return value to GUI?


Recommended Posts

I have a GUI. I would like when a button is pressed on that GUI that another GUI opens with a listbox on it that displays a list of items to chose from. When the user choses one, the value should be returned to the main form.

I can do all of that except figure out how to pass the Selected item from the listbox form back to the main gui? I could do it the cheap way and write to the registry or something then have my main form read that registry entry, but I know from searching around there must be a way to pass the selection directly from the listbox GUI back to the main GUI? The forum searches I've done though so far haven't been helpful for me.

Thanks,

Terry

Link to comment
Share on other sites

$Frm_main = GUICreate("Test form")
$Btn_Test = GUICtrlCreateButton("test", 10, 10, 60, 25")
$Lbl = GUICtrlCreateLabel("", 10, 40, 60, 20)
Global $sVal

$Frm_2 = GUICreate("Form 2")
$List = GUICtrlCreateList("Apples|Oranges|Pears", 10, 10, 80, 40)

GUISetState($Frm_Main)

While 1
    $msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $Btn_Test
            GUISetState(@SW_HIDE, $Frm_Main)
            GUISetState(@SW_SHOW, $Frm_2)
            GUISwitch($Frm_2
        Case $List
            $sVal = GUICtrlRead($List) ;;  You can actually use $Val = GUICtrlRead($msg) here
            GUISetState(@SW_SHOW, $Frm_main)
            GUISwitch($Frm_Main)
            GUIsetState(@SW_HIDE, $Frm_2
            GUICtrlSetData($Lbl, $sval)
    EndSwitch
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...