Page 1 of 1

Posted: Tue Sep 24, 2002 8:57 am
by BackupUser
Restored from previous forum. Originally posted by WolfgangS.

Hi !
I discovered a few strange effects in correlation with 2 Windows.
If i open my 'Motherwindow'and open a 2nd Window (for preferences) in
a procedure, i can close it, but after this, i can't do anything
anymore with the MotherWindow.
If i use UseWindow() nothing happends !!???!?!
Probably there is some stuff to do but i don't know what .... Any
help ?

MFG
:)WolfgangS


Code: Select all

#ID_MWindow =0  ; Mother
#ID_SWindow =1  ; Second

#ID_Button1 =10
#ID_Button2 =11

Procedure openwindow2()
  hnd_SWindow=OpenWindow(#ID_SWindow,200,200,200,200,0,"Second Window")
  If CreateGadgetList(hnd_SWindow)
    ButtonGadget(#ID_Button2,50,50,50,20,"Exit")
  EndIf

  Repeat
    Event=WaitWindowEvent()
    If Event=#PB_EventGadget
      If EventGadgetID()=#ID_Button2
        CloseWindow(#ID_SWindow)
      EndIf
    EndIf
  Until ForEver
EndProcedure


hnd_MWindow=OpenWindow(#ID_MWindow,100,200,200,200,#PB_Window_SystemMenu,"Test")
If CreateGadgetList(hnd_MWindow)
  ButtonGadget(#ID_Button1,50,50,50,20,"Open")
EndIf

Repeat
  Event=WaitWindowEvent()
  If Event=#PB_EventGadget     
    If EventGadgetID()=#ID_Button1
      openwindow2()
    EndIf
  EndIf
Until Event=#PB_Event_CloseWindow


Posted: Tue Sep 24, 2002 9:49 am
by BackupUser
Restored from previous forum. Originally posted by Pupil.

If you're stuck try to step through you program by first calling CallDebugger and then the step-button in the debugger window. Then you would have seen what's wrong :)

What happends is this: You close the window in the procedure but you're not exiting the procedure this means that the WaitWindowEvent() waits forever because you've got no window. Just add this 'ProcedureRereturn' right after the CloseWindow() command and you're program will not hang.

Posted: Tue Sep 24, 2002 10:47 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

You can also do this in 1 Event loop:

Code: Select all

#ID_MWindow =0  ; Mother
#ID_SWindow =1  ; Second

#ID_Button1 =10
#ID_Button2 =11

Procedure openwindow2()
  hnd_SWindow=OpenWindow(#ID_SWindow,200,200,200,200,0,"Second Window")
  If CreateGadgetList(hnd_SWindow)
    ButtonGadget(#ID_Button2,50,50,50,20,"Exit")
  EndIf
EndProcedure


hnd_MWindow=OpenWindow(#ID_MWindow,100,200,200,200,#PB_Window_SystemMenu,"Test")
If CreateGadgetList(hnd_MWindow)
  ButtonGadget(#ID_Button1,50,50,50,20,"Open")
EndIf

Repeat
  Event = WaitWindowEvent()
     If Event=#PB_EventGadget     
        Select EventGadgetID()
          Case #ID_Button1: openwindow2()
          Case #ID_Button2: CloseWindow(#ID_SWindow)
        EndSelect
     EndIf
Until Event=#PB_Event_CloseWindow And EventWindowID() = #ID_MWindow
cya,
...Danilo

(registered PureBasic user)

Posted: Tue Sep 24, 2002 5:41 pm
by BackupUser
Restored from previous forum. Originally posted by WolfgangS.

Hi
thanks for info. :)

MFG
WolfgangS