Jump to content

Linking Multiple Boxes to a previous ctrl


Dreidor
 Share

Recommended Posts

Hi, I'm trying to create my first gui, and i'm searching a easy way to link multiple boxes (1,2,3,4,5,6) to a control (primary) that has 4 choice (a,b,c,d)

I've been already successful to link one box to 2 ctrl, but now that i need to link 6 boxes to only one ctrl, i'm searching for a clean code solution: what i have now is:

func changeboxes()
$statsw = GUICtrlRead($primary)
Switch $statsw
Case 'a'
GUICtrlSetData($1, '')
guictrlsetdata($2, '')
GUICtrlSetData($1, "test")
guictrlsetdata($2, "test")

etc etc, for 6 boxes and 4 cases....

Now... is there a good solution to keep the code clean?

I hope i've chosen the right words to make the problem clear ^^'

Thanks

Link to comment
Share on other sites

What do you mean when you say "boxes"?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Post the code you've tried so far, because I'm not 100% sure of what it is you're trying to accomplish and I don't want to have to come up with a solution that doesn't do what you want it to do.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok, thanks again:

$primary = GUICtrlCreateCombo("", 48, 112, 250, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($primary, "test1a|test1b|test1c|test1d", "test1")
GUICtrlSetOnEvent($primary, "setsecondary")


$stat1 = GUICtrlCreateCombo("", 48, 392, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat1, "Preferred Stat")
GUICtrlSetResizing($stat1, $gui_dockall)
$stat2 = GUICtrlCreateCombo("", 48, 432, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat2, "Preferred Stat")
GUICtrlSetResizing($stat2, $gui_dockall)
$stat3 = GUICtrlCreateCombo("", 48, 472, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat3, "Preferred Stat")
GUICtrlSetResizing($stat3, $gui_dockall)
$stat4 = GUICtrlCreateCombo("", 48, 512, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat4, "Preferred Stat")
GUICtrlSetResizing($stat4, $gui_dockall)
$stat5 = GUICtrlCreateCombo("", 48, 552, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat5, "Preferred Stat")
GUICtrlSetResizing($stat5, $gui_dockall)
$stat6 = GUICtrlCreateCombo("", 48, 592, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "bla1|bla2|bla3")
GUICtrlSetTip($stat6, "Preferred Stat")
GUICtrlSetResizing($stat6, $gui_dockall)

func setsecondary()
$statsw = GUICtrlRead($primary)
Switch $statsw
Case '1-Hand'
GUICtrlSetData($1, '')
GUICtrlSetData($2, '')
GUICtrlSetData($3, '')
GUICtrlSetData($4, '')
GUICtrlSetData($5, '')
GUICtrlSetData($6, '')
GUICtrlSetData($1, "bla1|bla2|bla3|bla4")
GUICtrlSetData($2, "bla1|bla2|bla3|bla4")
GUICtrlSetData($3, "bla1|bla2|bla3|bla4")
GUICtrlSetData($4, "bla1|bla2|bla3|bla4")
GUICtrlSetData($5, "bla1|bla2|bla3|bla4")
GUICtrlSetData($6, "bla1|bla2|bla3|bla4")
Case '2-Hand'
GUICtrlSetData($1, '')
GUICtrlSetData($2, '')
GUICtrlSetData($3, '')
GUICtrlSetData($4, '')
GUICtrlSetData($5, '')
GUICtrlSetData($6, '')
GUICtrlSetData($1, "blaA|blaB|blaC|blaD")
GUICtrlSetData($2, "blaA|blaB|blaC|blaD")
GUICtrlSetData($3, "blaA|blaB|blaC|blaD")
GUICtrlSetData($4, "blaA|blaB|blaC|blaD")
GUICtrlSetData($5, "blaA|blaB|blaC|blaD")
GUICtrlSetData($6, "blaA|blaB|blaC|blaD")
Case 'Off-Hand'
GUICtrlSetData($1, '')
GUICtrlSetData($2, '')
GUICtrlSetData($3, '')
GUICtrlSetData($4, '')
GUICtrlSetData($5, '')
GUICtrlSetData($6, '')
GUICtrlSetData($1, "bla1a|bla1b|bla1c|bla1d")
GUICtrlSetData($2, "bla1a|bla1b|bla1c|bla1d")
GUICtrlSetData($3, "bla1a|bla1b|bla1c|bla1d")
GUICtrlSetData($4, "bla1a|bla1b|bla1c|bla1d")
GUICtrlSetData($5, "bla1a|bla1b|bla1c|bla1d")
GUICtrlSetData($6, "bla1a|bla1b|bla1c|bla1d")
Case 'Armor'
GUICtrlSetData($1, '')
GUICtrlSetData($2, '')
GUICtrlSetData($3, '')
GUICtrlSetData($4, '')
GUICtrlSetData($5, '')
GUICtrlSetData($6, '')
GUICtrlSetData($1, "bla2a|bla2b|bla2c|bla2d")
GUICtrlSetData($2, "bla1a|bla2b|bla2c|bla2d")
GUICtrlSetData($3, "bla1a|bla2b|bla2c|bla2d")
GUICtrlSetData($4, "bla1a|bla2b|bla2c|bla2d")
GUICtrlSetData($5, "bla1a|bla2b|bla2c|bla2d")
GUICtrlSetData($6, "bla1a|bla2b|bla2c|bla2d")
EndSwitch
EndFunc
Link to comment
Share on other sites

There's a lot of code missing in your script, this doesn't even run, and I'm still not sure what it is you're trying to do with it. For one thing, you don't have any controls assigned to $1, $2, $3, etc.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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