Restored from previous forum. Originally posted by merendo.
Procedure window()
OpenWindow(1,20,20,158,100,0,"Another Test")
CreateGadgetList(WindowID())
ButtonGadget(1,8,8,136,25,"Do something")
GadgetToolTip(1,"Does something")
ButtonGadget(2,8,41,136,25,"Close")
GadgetToolTip(2,"Closes this window")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case 1
MessageRequester("Something","Something for nothing",0)
Case 2
CloseWindow(1)
EndSelect
EndIf
ForEver
ProcedureReturn 0
EndProcedure
InitGadget(2)
OpenWindow(0,10,10,400,300,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget,"Test")
CreateGadgetList(WindowID())
ButtonGadget(0,8,8,200,25,"Click here to open a window")
GadgetToolTip(0,"Opens a second window")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case 0
window()
EndSelect
EndIf
Until event = #PB_EventCloseWindow
If I try this code it seems to work fine, but if I click "Click here to open a window" the window opens. Then, if I close the second window, all the gadgets of the first window don´t work. Is this normal or a bug??? Thank you, merendo
We always need to hear both sides of the story (by Phil Collins)
Gadget (Bug???)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
Change your code to this (additions marked by *****):
PB - Registered PureBasic Coder
Edited by - PB on 03 April 2002 02:56:51
Change your code to this (additions marked by *****):
Code: Select all
Procedure window()
OpenWindow(1,20,20,158,100,0,"Another Test")
CreateGadgetList(WindowID())
ButtonGadget(1,8,8,136,25,"Do something")
GadgetToolTip(1,"Does something")
ButtonGadget(2,8,41,136,25,"Close")
GadgetToolTip(2,"Closes this window")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case 1
MessageRequester("Something","Something for nothing",0)
Case 2
quit=1 ; ***** So we know that this window must quit.
EndSelect
EndIf
Until quit=1 ; ***** Loop events until quit time.
CloseWindow(1)
ProcedureReturn 0
EndProcedure
;
InitGadget(2)
OpenWindow(0,10,10,400,300,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget,"Test")
CreateGadgetList(WindowID())
ButtonGadget(0,8,8,200,25,"Click here to open a window")
GadgetToolTip(0,"Opens a second window")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case 0
window()
UseWindow(0) ; ***** Use window 0's events again.
EndSelect
EndIf
Until event = #PB_EventCloseWindow
PB - Registered PureBasic Coder
Edited by - PB on 03 April 2002 02:56:51
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Merendo this can't work.
You close the 2nd window but never get out of your 'Repeat' loop. ('Forever'...and ever)
That's why PB changed 'Forever' with 'Until'.
Just a note to explain what's going on
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Repeat
...
Select EventGadgetID()
...
Case 2
CloseWindow(1)
EndSelect
...
ForEver
Hi Merendo this can't work.
You close the 2nd window but never get out of your 'Repeat' loop. ('Forever'...and ever)
That's why PB changed 'Forever' with 'Until'.
Just a note to explain what's going on
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.