AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

create a gui depending on the data from 1st gui

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
edu



Joined: 12 Oct 2006
Posts: 88
Location: Canada

PostPosted: Thu Jan 10, 2008 1:29 am    Post subject: create a gui depending on the data from 1st gui Reply with quote

Good evening, users!
I have these two (prototype) gui scripts:

Code:
Gui, Font, S11 CDefault, Verdana
Gui, Add, Text,, How many boxes for this shipment?
Gui, Add, Edit, vBoxes, 1 ; Input the number of boxes
Gui, Add, ComboBox, vTipo , Door-to-Station||Door-to-Door ; service type
Gui, Add, Button, default, OK
Gui, Show, , Shipments
return

ButtonOK:
Gui, Submit


The number of edit boxes and check boxes in this second gui should depend on the number of boxes inputes in the control Edit in the second gui. If the user has enter 2 boxes, the the second gui should look like this:

Code:
Gui, Font, S11 CDefault, Verdana
Gui, Add, CheckBox, vCheck1, Oversized?
Gui, Add, CheckBox, vCheck2, Oversized?
Gui, Add, Edit, ym vBox1,
Gui, Add, Edit, vBox2,
Gui, Add, Button, default, OK
Gui, Show, , Boxes (Weight in Pounds)
Return

ButtonOK:
Gui, Submit

GuiClose:
ExitApp


How can I code the first script so that it will generate as many checkboxes and edit controls as it is inputed?

Thanks, edu.
_________________
The best things of life are free.
Back to top
View user's profile Send private message
maximo3491



Joined: 10 Feb 2007
Posts: 65

PostPosted: Thu Jan 10, 2008 2:07 am    Post subject: Reply with quote

If the 2 guis are in the same program, you can do the following, after he picks the number of edit boxes in the first GUI and pressing OK, the second GUI would activate and within the adding of controls to the second GUI, you can do the following...

Code:
GUI, submit, nohide
loop %Boxes%
{
gui2, add, edit, vbox%A_index%
}


Make sure to give the second gui a new id, like gui2.

Also, in my snippet, to access the values of each edit boxes, the variables are box1, box2, box3, etc..
Back to top
View user's profile Send private message
edu



Joined: 12 Oct 2006
Posts: 88
Location: Canada

PostPosted: Thu Jan 10, 2008 5:08 pm    Post subject: Reply with quote

Thanks for your help so far. But I developed this code and I get an error:
Code:
Gui, Font, S11 CDefault, Verdana
Gui, Add, Text,, How many boxes for this shipment?
Gui, Add, Edit, vBoxes, 1 ; Input the number of boxes
Gui, Add, ComboBox, vTipo , Door-to-Station||Door-to-Door ; service type
Gui, Add, Button, default, OK
Gui, Show, , Shipments
return

ButtonOK:
Gui, Submit, NoHide
Loop %Boxes%
{
Gui2, add, edit, vpack%A_index% ; <== Error: This line does not contain a recognized action.
Gui2, Add, CheckBox, vCheck%A_index%, Oversized?
}
Gui2, Add, Button, default, OK
Gui2, Show, , Boxes (Weight in Pounds)
Return

ButtonOK:
Gui2, Submit

GuiClose:
ExitApp


Also how can I make sure that there will be 2 columns, with the checkbox beside the edit box?
_________________
The best things of life are free.
Back to top
View user's profile Send private message
Mustang



Joined: 17 May 2007
Posts: 375
Location: England

PostPosted: Fri Jan 11, 2008 1:50 am    Post subject: Reply with quote

Replace:
Code:
Gui2,

With:
Code:
Gui, 2:


e.g. "Gui2, Add" -> "Gui, 2:Add"
Back to top
View user's profile Send private message
dmatch



Joined: 15 Oct 2007
Posts: 113

PostPosted: Sat Jan 26, 2008 5:44 pm    Post subject: Reply with quote

Edited: I posted in response to a question regarding how to put the info from Gui2 in a file. It appears that the post was deleted just before I replied.


Just before ExitApp you can write the info to a file similar to this:
Code:
Loop % Boxes
   FileAppend, % (A_Index . "," . A_Now . "," . pack%A_Index% . "," . Check%A_Index% . "`n"), C:\YourFileNameHere.ext

This presumes you want to know when the data was entered (%A_Now%) and want to also keep track of the package (A_Index), the weight (pack%A_Index%), and if it is oversized (Check%A_Index%). This uses a comma delimiter but obviously you can change that if you want to. You also could format the date/time as you see fit by choosing other "A_ " built in variables and stringing them together.

To test without writing to a file you just use a MsgBox:
Code:
   MsgBox, % (A_Index . "," . A_Now . "," . pack%A_Index% . "," . Check%A_Index% . "`n")


dmatch
Back to top
View user's profile Send private message
Baronred



Joined: 24 Jan 2008
Posts: 1

PostPosted: Sat Jan 26, 2008 6:13 pm    Post subject: Reply with quote

Thanks, dmatch, for the quick reply. That is exactly what I was trying to accomplish. I'm new to AHK but I'm learning fast.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group