control 2 windows in the same program

Just starting out? Need help? Post your questions and find answers here.
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

control 2 windows in the same program

Post by RJP Computing »

How do you control 2 windows in the same program starting with the visual designer event loop. I have a problem where if I close a popup window it closes the whole loop.

Thanks
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

never took a closer look on the generated Source of VD yet but you can use WindowEventID to determine which window fired the event and only close the window on which the event occured.

Possible some changes on the eventloop of VD may be needed.

Mike
Tranquil
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

Post by RJP Computing »

Here is a quick example of the event loop. I did use that command but I don't know how to catch the 'x' close event and just close that window.

Code: Select all

Repeat
  
  Event = WaitWindowEvent() 
  
  If EventWindowID() = #Window_Main
  
    If Event = #PB_EventMenu
      
      ;Debug "WindowID: " + Str(EventWindowID())
      
      MenuID = EventMenuID()
      
      If MenuID = #MENU_NEW
        Debug "GadgetID: #MENU_NEW"
        
      ElseIf MenuID = #MENU_EXIT
        Debug "GadgetID: #MENU_EXIT"
        ;CloseWindow(#Window_Main)
        Event = #PB_EventCloseWindow
      ElseIf MenuID = #MENU_ABOUT
        Debug "GadgetID: #MENU_ABOUT"
        OpenWindow(#Window_About, 0, 0, 250, 350,  #PB_Window_SystemMenu , "About RJPad Lite v0.01", WindowID(#Window_Main))

      EndIf
      
    EndIf
    
    If Event = #PB_EventGadget
      
      ;Debug "WindowID: " + Str(EventWindowID())
      
      GadgetID = EventGadgetID()
      
      If GadgetID = #Gadget_Editor
        ;Debug "GadgetID: #Gadget_Editor"
        
      EndIf
      
    EndIf
    
  EndIf
  
  
  
Until Event = #PB_EventCloseWindow

End
Thanks
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4792
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

see if this helps a bit more

Post by Fangbeast »

Code: Select all

#MainWindow    = 1
#Window1         = 2
#Window2         = 3
#Window3         = 4
#Window4         = 5
#Window5         = 6
#Window6         = 7
#Window_About = 8

Repeat 
  
  EventID = WaitWindowEvent() 
  
    If EventID = #PB_Event_CloseWindow
      Select EventWindowID()
        Case #Window1 : CloseWindow(#Window1)
        Case #Window2 : CloseWindow(#Window2)
        Case #Window3 : CloseWindow(#Window3)
        Case #Window4 : CloseWindow(#Window4)
        Case #Window5 : CloseWindow(#Window5)
        Case #Window6 : CloseWindow(#Window6)
        Case #Window6 : CloseWindow(#Window7)
        Case #Window_About : CloseWindow(#Window_About)
      EndSelect
    EndIf
    
    If EventID = #PB_EventMenu 
      MenuID = EventMenuID() 
      Select MenuID
        Case #MENU_NEW   : Debug "GadgetID: #MENU_NEW" 
        Case #MENU_EXIT  : Debug "GadgetID: #MENU_EXIT" 
        Case #MENU_ABOUT : Debug "GadgetID: #MENU_ABOUT" 
        OpenWindow(#Window_About, 0, 0, 250, 350,  #PB_Window_SystemMenu , "About RJPad Lite v0.01", WindowID(#Window_Main)) 
      EndSelect
    EndIf 
      
    If EventID = #PB_EventGadget 
      GadgetID = EventGadgetID() 
        Select GadgetID
          Case #Gadget_Editor : ; Debug "GadgetID: #Gadget_Editor" 
        EndSelect
    EndIf 
      
Until EventID = #PB_EventCloseWindow And EventWindowID() = #MainWindow

Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
RJP Computing
Enthusiast
Enthusiast
Posts: 202
Joined: Sun Apr 27, 2003 4:44 am
Location: Michigan, USA
Contact:

Post by RJP Computing »

Thanks Fangbeast,
That is exactly what I needed. Sometimes the obvious eludes me.

Thanks
-Ryan
RJP Computing

Ubuntu 8.10/WinXP, AMD Athlon 64 3000+, 1000MB RAM, AC 97 Audio, nVidia GeForce 7600GT 512MB
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4792
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

:):)

Post by Fangbeast »

You should see how many times I got myself into trouble with this one myself till I figured out what I was doing. :):)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply