1º In window1 when i press "add 1" button it adds to textbox (it's working).
2º Then i open window2 and press "add 1" button and it adds to textbox in window1.
3º Then when i go back to window 1 and press "add 1" button it doesn't work anymore.
What i am doing wrong ? I don't want to close window2.
Code: Select all
Enumeration
#window1
#window1_button1
#window1_button2
#window1_text1
#window2
#window2_button1
EndEnumeration
Declare p_window1_ini()
Declare p_window2_ini()
Declare p_window1_control()
Declare p_window2_control()
Global n=0
If OpenWindow(#window1, 0, 0, 800, 600, "window1",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
p_window1_ini()
p_window1_control()
EndIf
End
Procedure p_window2()
If OpenWindow(#window2, 0, 0, 400, 300, "window2",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
StickyWindow(#Window2, #True)
p_window2_ini()
p_window2_control()
CloseWindow(#window2)
EndIf
EndProcedure
Procedure p_window1_ini()
ButtonGadget(#window1_button1, 10, 10, 150, 20, "Open Window2")
ButtonGadget(#window1_button2, 10, 30, 150, 20, "Add 1")
TextGadget(#window1_text1, 10, 50, 150, 20, Str(n),#PB_Text_Border)
EndProcedure
Procedure p_window2_ini()
ButtonGadget(#window2_button1, 10, 30, 150, 20, "Add 1")
EndProcedure
Procedure p_window1_control()
Protected window1_event
Repeat
window1_event=WaitWindowEvent()
Select window1_event
Case #PB_Event_Gadget
Select EventGadget()
Case #window1_button1
p_window2()
Case #window1_button2
n=n+1
SetGadgetText(#window1_text1,Str(n))
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndProcedure
Procedure p_window2_control()
Protected window2_event
Repeat
window2_event=WaitWindowEvent()
Select window2_event
Case #PB_Event_Gadget
Select EventGadget()
Case #window2_button1
n=n+1
SetGadgetText(#window1_text1,Str(n))
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndProcedure



