xsnow Posted August 21, 2008 Share Posted August 21, 2008 my code. expandcollapse popupGUICreate("Checkbook Finance",200,250) $adddeposit=GUICtrlCreateButton ("Deposit", 65,10,70,25) $addwithdrawl=GUICtrlCreateButton ("Withdrawal", 65,45,70,25) $update=GUICtrlCreateButton ("Update Balance", 55,80,90,25) $test=GUICtrlCreateButton ("test", 55,110,90,25) $close=GUICtrlCreateButton ("Close", 65,145,70,25) GUICtrlCreateLabel ("Account Balance : $"&$balance, 65,175,70,75) ;then under test i run Func test() GUICreate(" Withdrawal Information ", 320,175) GUICtrlCreateLabel ("Date : ", 10,5,125,25) $date = GUICtrlCreateInput ( "Withdrawal", 135, 5, 300, 20) GUICtrlCreateLabel ("Withdrawal Date : ", 10,35,125,25) $name = GUICtrlCreateInput ( "Withdrawal", 135, 35, 300, 20) GUICtrlCreateLabel ("Withdrawal Name : ", 10,35,125,25) $amount = GUICtrlCreateInput ( "Withdrawal", 135, 65, 300, 20) GUICtrlCreateLabel ("Withdrawal Amount : ", 10,65,125,25) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $msg = $GUI_EVENT_CLOSE Exitloop EndSelect Wend ;MsgBox (4096, "drag drop file", GUICtrlRead($name)) EndFunc but it closes both guis what do i need to do different? Link to comment Share on other sites More sharing options...
Achilles Posted August 21, 2008 Share Posted August 21, 2008 #include <GUIConstantsEx.au3> GUICreate("Checkbook Finance",200,250) $adddeposit=GUICtrlCreateButton ("Deposit", 65,10,70,25) $addwithdrawl=GUICtrlCreateButton ("Withdrawal", 65,45,70,25) $update=GUICtrlCreateButton ("Update Balance", 55,80,90,25) $test=GUICtrlCreateButton ("test", 55,110,90,25) $close=GUICtrlCreateButton ("Close", 65,145,70,25) GUICtrlCreateLabel ("Account Balance : $", 65,175,70,75) GUiSetState() ;then under test i run test() Func test() GUICreate(" Withdrawal Information ", 320,175) GUICtrlCreateLabel ("Date : ", 10,5,125,25) $date = GUICtrlCreateInput ( "Withdrawal", 135, 5, 300, 20) GUICtrlCreateLabel ("Withdrawal Date : ", 10,35,125,25) $name = GUICtrlCreateInput ( "Withdrawal", 135, 35, 300, 20) GUICtrlCreateLabel ("Withdrawal Name : ", 10,35,125,25) $amount = GUICtrlCreateInput ( "Withdrawal", 135, 65, 300, 20) GUICtrlCreateLabel ("Withdrawal Amount : ", 10,65,125,25) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () While 1 Switch GUiGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() EndSwitch Wend ;MsgBox (4096, "drag drop file", GUICtrlRead($name)) EndFuncThis is a kind of messy way to do it. I don't think you'll be able to manage both GUI at once if you do it this way. Look at the function GUICtrlSetOnEvent(), it would make your job easier. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
xsnow Posted August 21, 2008 Author Share Posted August 21, 2008 #include <GUIConstantsEx.au3> GUICreate("Checkbook Finance",200,250) $adddeposit=GUICtrlCreateButton ("Deposit", 65,10,70,25) $addwithdrawl=GUICtrlCreateButton ("Withdrawal", 65,45,70,25) $update=GUICtrlCreateButton ("Update Balance", 55,80,90,25) $test=GUICtrlCreateButton ("test", 55,110,90,25) $close=GUICtrlCreateButton ("Close", 65,145,70,25) GUICtrlCreateLabel ("Account Balance : $", 65,175,70,75) GUiSetState() ;then under test i run test() Func test() GUICreate(" Withdrawal Information ", 320,175) GUICtrlCreateLabel ("Date : ", 10,5,125,25) $date = GUICtrlCreateInput ( "Withdrawal", 135, 5, 300, 20) GUICtrlCreateLabel ("Withdrawal Date : ", 10,35,125,25) $name = GUICtrlCreateInput ( "Withdrawal", 135, 35, 300, 20) GUICtrlCreateLabel ("Withdrawal Name : ", 10,35,125,25) $amount = GUICtrlCreateInput ( "Withdrawal", 135, 65, 300, 20) GUICtrlCreateLabel ("Withdrawal Amount : ", 10,65,125,25) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () While 1 Switch GUiGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() EndSwitch Wend ;MsgBox (4096, "drag drop file", GUICtrlRead($name)) EndFuncThis is a kind of messy way to do it. I don't think you'll be able to manage both GUI at once if you do it this way. Look at the function GUICtrlSetOnEvent(), it would make your job easier. It will close but cancels my close button on my other gui. full code for you expandcollapse popup#include <String.au3> #include <array.au3> #include <file.au3> #include <GUIConstants.au3> Global $deposit = "C:\Documents and Settings\Parker\Desktop\BA\deposits.txt" Global $withdrawal = "C:\Documents and Settings\Parker\Desktop\BA\withdrawals.txt" dim $depositamount, $withdrawalamount, $balance, $filedeposit, $filedeposit, $line, $flag, $adddeposit, $addwithdrawl, $totaldeposits = 0, $totalwithdrawals = 0, $close, $update $filedeposit = FileOpen($deposit, 1) $filewithdrawal = FileOpen($withdrawal, 1) Balance() GUICreate("Checkbook Finance",200,250) $adddeposit=GUICtrlCreateButton ("Deposit", 65,10,70,25) $addwithdrawl=GUICtrlCreateButton ("Withdrawal", 65,45,70,25) $update=GUICtrlCreateButton ("Update Balance", 55,80,90,25) $test=GUICtrlCreateButton ("test", 55,110,90,25) $close=GUICtrlCreateButton ("Close", 65,145,70,25) GUICtrlCreateLabel ("Account Balance : $"&$balance, 65,175,70,75) GUISetState () $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select case $msg = $adddeposit Deposit() case $msg = $addwithdrawl Withdrawal() case $msg = $update Balance() GUICtrlCreateLabel ("Account Balance : $"&$balance, 65,175,70,75) case $msg = $test test() case $msg = $close FileClose($deposit) FileClose($Withdrawal) Exit EndSelect Wend Func Balance() $balance = 0 $totaldeposits = 0 $totalwithdrawals = 0 $line = 0 If Not _FileReadToArray($deposit,$line) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $i = 1 to $line[0] $totaldeposits = $line[$i] + $totaldeposits Next If Not _FileReadToArray($withdrawal,$line) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $i = 1 to $line[0] $totalwithdrawals = $line[$i] + $totalwithdrawals Next $balance = $totaldeposits - $totalwithdrawals EndFunc Func Deposit() $depositamount = Inputbox("Deposit", "How much?") If @Error = 1 Then MsgBox(4096, "Deposit Canceled", "No Deposit Was Entered") Else If @Error = 0 Then $flag = Msgbox (4, "Is the information correct?", "Deposit of $"&$depositamount) If $flag = 6 Then FileWrite($deposit, $depositamount & @CRLF) Else MsgBox(4096, "Deposit Canceled", "No Deposit Was Entered") EndIf EndIf EndIf EndFunc Func Withdrawal() $withdrawalamount = Inputbox("Withdrawal", "How much?") If @Error = 1 Then MsgBox(4096, "Withdrawal Canceled", "No Withdrawal Was Entered") Else If @Error = 0 Then $flag = Msgbox (4, "Is the information correct?", "Withdrawal of $"&$withdrawalamount) If $flag = 6 Then FileWrite($withdrawal, $withdrawalamount & @CRLF) Else MsgBox(4096, "Withdrawal Canceled", "No Withdrawal Was Entered") EndIf EndIf EndIf EndFunc Func test() GUICreate(" Withdrawal Information ", 320,175) GUICtrlCreateLabel ("Date : ", 10,5,125,25) $date = GUICtrlCreateInput ( "Withdrawal", 135, 5, 300, 20) GUICtrlCreateLabel ("Withdrawal Date : ", 10,35,125,25) $name = GUICtrlCreateInput ( "Withdrawal", 135, 35, 300, 20) GUICtrlCreateLabel ("Withdrawal Name : ", 10,35,125,25) $amount = GUICtrlCreateInput ( "Withdrawal", 135, 65, 300, 20) GUICtrlCreateLabel ("Withdrawal Amount : ", 10,65,125,25) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () While 1 Switch GUiGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() EndSwitch Wend ;MsgBox (4096, "drag drop file", GUICtrlRead($name)) EndFunc I'll look over it at work a bit, don't have AI there but i'll see what I can dig through on the forums Link to comment Share on other sites More sharing options...
Spiff59 Posted August 21, 2008 Share Posted August 21, 2008 (edited) If not for functional purposes, then for clarity/documentation purposes, I'd think you'd be wanting to assign the handle/object returned by your GUICreate calls to program variables to make it clear what is the target of your GUIDelete. $GUI_Checkbook = GUICreate("Checkbook Finance",200,250) $GUI_Withdrawal = GUICreate(" Withdrawal Information ", 320,175) GUIDelete($GUI_Withdrawal) Edit: I chopped it up a little, hope you don't mind. Might give you something to play with (I just did what I'd mentioned above, and split up your balance label and disabled your main gui until the secondary is closed): expandcollapse popup#include <String.au3> #include <array.au3> #include <file.au3> #include <GUIConstants.au3> Global $deposit = "C:\Documents and Settings\Parker\Desktop\BA\deposits.txt" Global $withdrawal = "C:\Documents and Settings\Parker\Desktop\BA\withdrawals.txt" dim $depositamount, $withdrawalamount, $balance, $filedeposit, $filedeposit, $line, $flag, $adddeposit, $addwithdrawl, $totaldeposits = 0, $totalwithdrawals = 0, $close, $update dim $GUI_Withdrawal, $Label_Balance, $btn $GUI_Checkbook = GUICreate("Checkbook Finance",200,250) $adddeposit=GUICtrlCreateButton ("Deposit", 65,10,70,25) $addwithdrawl=GUICtrlCreateButton ("Withdrawal", 65,45,70,25) $update=GUICtrlCreateButton ("Update Balance", 55,80,90,25) $test=GUICtrlCreateButton ("test", 55,110,90,25) $close=GUICtrlCreateButton ("Close", 65,145,70,25) GUICtrlCreateLabel ("Account Balance: $", 30,192,96,20) $Label_Balance = GUICtrlCreateLabel ($balance, 128,192,80,20) GUISetState () $filedeposit = FileOpen($deposit, 1) $filewithdrawal = FileOpen($withdrawal, 1) Balance() ;-------------------------------------------------------------------------------------- While 1 $msg = GUIGetMsg() Switch $msg case $adddeposit Deposit() case $addwithdrawl Withdrawal() case $update Balance() case $test test() Case $close, $GUI_EVENT_CLOSE ExitLoop EndSwitch Wend Exit ;-------------------------------------------------------------------------------------- Func Balance() $balance = 0 $totaldeposits = 0 $totalwithdrawals = 0 $line = 0 If Not _FileReadToArray($deposit,$line) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $i = 1 to $line[0] $totaldeposits += $line[$i] Next If Not _FileReadToArray($withdrawal,$line) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $i = 1 to $line[0] $totalwithdrawals += $line[$i] Next $balance = $totaldeposits - $totalwithdrawals GUICtrlSetData($Label_Balance, $balance) EndFunc ;-------------------------------------------------------------------------------------- Func Deposit() $depositamount = Inputbox("Deposit", "How much?") If @Error = 1 Then MsgBox(4096, "Deposit Canceled", "No Deposit Was Entered") Else If @Error = 0 Then $flag = Msgbox (4, "Is the information correct?", "Deposit of $"&$depositamount) If $flag = 6 Then FileWrite($deposit, $depositamount & @CRLF) Else MsgBox(4096, "Deposit Canceled", "No Deposit Was Entered") EndIf EndIf EndIf EndFunc ;-------------------------------------------------------------------------------------- Func Withdrawal() $withdrawalamount = Inputbox("Withdrawal", "How much?") If @Error = 1 Then MsgBox(4096, "Withdrawal Canceled", "No Withdrawal Was Entered") Else If @Error = 0 Then $flag = Msgbox (4, "Is the information correct?", "Withdrawal of $"&$withdrawalamount) If $flag = 6 Then FileWrite($withdrawal, $withdrawalamount & @CRLF) Else MsgBox(4096, "Withdrawal Canceled", "No Withdrawal Was Entered") EndIf EndIf EndIf EndFunc ;-------------------------------------------------------------------------------------- Func test() GUISetState(@SW_DISABLE,$GUI_Checkbook) $GUI_Withdrawal = GUICreate(" Withdrawal Information ", 320,175) GUICtrlCreateLabel ("Date : ", 10,5,125,25) $date = GUICtrlCreateInput ( "Withdrawal", 135, 5, 300, 20) GUICtrlCreateLabel ("Withdrawal Date : ", 10,35,125,25) $name = GUICtrlCreateInput ( "Withdrawal", 135, 35, 300, 20) GUICtrlCreateLabel ("Withdrawal Name : ", 10,35,125,25) $amount = GUICtrlCreateInput ( "Withdrawal", 135, 65, 300, 20) GUICtrlCreateLabel ("Withdrawal Amount : ", 10,65,125,25) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GUISetState () While 1 Switch GUiGetMsg() Case $btn, $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE,$GUI_Checkbook) GUIDelete($GUI_Withdrawal) ExitLoop EndSwitch Wend ; MsgBox (4096, "drag drop file", GUICtrlRead($name)) EndFunc Edited August 21, 2008 by Spiff59 Link to comment Share on other sites More sharing options...
xsnow Posted August 22, 2008 Author Share Posted August 22, 2008 ok that works quite well. I see you did a few things different than I had them which is a good thing. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now