Sign in to follow this  
Followers 0
yawoo

Dynamic GUI

8 posts in this topic

I would like to create a dynmaic GUI, say,

there is a first listbox to control the remaining GUI control box showing.

Is there any special technique to do so?

Share this post


Link to post
Share on other sites



i just copied and pasted cuz its early in the morning and dont feel like thinking, but you could easily reduce and make it alot nicer by using Arrays and For Next loops, lol u only have one option so the example isnt that great Ill whip up a better one if im home today

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$list1 = GUICtrlCreateList("", 40, 80, 145, 214)
GUICtrlSetData(-1,"A|B|C")
$list2 = GUICtrlCreateList("", 232, 80, 145, 214)
$list3 = GUICtrlCreateList("", 424, 80, 145, 214)
GUICtrlCreateLabel("1", 88, 56, 10, 17)
GUICtrlCreateLabel("2", 280, 64, 10, 17)
GUICtrlCreateLabel("3", 496, 64, 10, 17)
GUISetState(@SW_SHOW)


While 1
$msg = GUIGetMsg()

If $msg = $list1 Then
    A()
Elseif $msg = $list2 Then
    B()
EndIf
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd




Func A()
    $1 = GUICtrlRead($list1)
    If $1 = "A" Then
    GUICtrlSetData($list2,"")
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list2,"D")
ElseIf $1 = "B" Then
    GUICtrlSetData($list2,"")
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list2,"E")
ElseIf $1 = "C" Then
    GUICtrlSetData($list2,"")
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list2,"F")
EndIf   
EndFunc

Func B()
$2 = GUICtrlRead($list2)
If $2 = "D" Then
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list3,"G")
ElseIf $2 = "E" Then
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list3,"H")
ElseIf $2 = "F" Then
    GUICtrlSetData($list3,"")
    GUICtrlSetData($list3,"I")
EndIf
EndFunc

Share this post


Link to post
Share on other sites

Thanks for your example.

I have not described clearly. The dynamic GUI control box may not

restrict to use listbox, it may also textbox, and other types. Moreover,

the number of dynamic GUI control box may varies depending on

the first control box.

Should I create all possible contol boxes at the first time, and hide/unhide

them depending on the selection of the first one?

Share this post


Link to post
Share on other sites

well i just assumed you wanted a listbox due to it being able to show many different things at once, and making them all at once without anything in them like i did would make it alot better cuz the person knows how many choices they have to go through

Share this post


Link to post
Share on other sites

Here is the code I wrote to update my GUI depending on the first listbox selected.

I also attach the screenshot results to illustrate what I want.

Really thanks for your idea. If there is any more intelligence way,

please let me know. Thx

Func GUIUpdate_AudioEnc()
    Select
        Case GuiCtrlRead($hAudioEnc) = "Mp3"
            GUICtrlSetState($hMP3Mode, $GUI_SHOW)
            GUICtrlSetState($hMP3Vol, $GUI_SHOW)
            GUICtrlSetState($hlblMP3Mode, $GUI_SHOW)
            GUICtrlSetState($hlblMP3Vol, $GUI_SHOW)     
            GUICtrlSetState($hAACMpeg, $GUI_HIDE)
            GUICtrlSetState($hAACObject, $GUI_HIDE)     
            GUICtrlSetState($hlblAACMpeg, $GUI_HIDE)
            GUICtrlSetState($hlblAACObject, $GUI_HIDE)              
        Case GuiCtrlRead($hAudioEnc) = "AAC"
            GUICtrlSetState($hAACMpeg, $GUI_SHOW)
            GUICtrlSetState($hAACObject, $GUI_SHOW)
            GUICtrlSetState($hlblAACMpeg, $GUI_SHOW)
            GUICtrlSetState($hlblAACObject, $GUI_SHOW)              
            GUICtrlSetState($hMP3Mode, $GUI_HIDE)
            GUICtrlSetState($hMP3Vol, $GUI_HIDE)
            GUICtrlSetState($hlblMP3Mode, $GUI_HIDE)
            GUICtrlSetState($hlblMP3Vol, $GUI_HIDE)                             
        Case Else
            GUICtrlSetState($hAACMpeg, $GUI_HIDE)
            GUICtrlSetState($hAACObject, $GUI_HIDE)
            GUICtrlSetState($hlblAACMpeg, $GUI_HIDE)
            GUICtrlSetState($hlblAACObject, $GUI_HIDE)      
            GUICtrlSetState($hMP3Mode, $GUI_HIDE)
            GUICtrlSetState($hMP3Vol, $GUI_HIDE)
            GUICtrlSetState($hlblMP3Mode, $GUI_HIDE)
            GUICtrlSetState($hlblMP3Vol, $GUI_HIDE)                     
    EndSelect
EndFunc

Share this post


Link to post
Share on other sites

i c now, so whats wrong with that? looks good to me

Share this post


Link to post
Share on other sites

Nothing wrong. It have to do many coding to handle dynamic GUI control.

Just want to ask any alternative way or standard way to do so.

Or can I group a number of GUI control, and hide/show the group instead of?

Share this post


Link to post
Share on other sites

you could make everything an array and have a for loop and it would be like

For $i = 1 to 10
Guictrlsetstate($choicebox[$i],@SW_HIDE)
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0