Jump to content

Dynamic GUI


yawoo
 Share

Recommended Posts

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
Link to comment
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?

Link to comment
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
Link to comment
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?

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