OK, I have vertigo with all the different "multiple windows" questions -- all interesting but none of them quite speaking to my use. I run simulations (evolutionary and genetic) but when items are ready I need to plot them in the appropriate window. I think what I'm saying is simplified as: 1) Make 3-5 Windows (one or more for images) the others are graphs to which data are added (plotted) periodically -- I need to see their progress en passant. 2) According to what is going on In my main loop (program), I want to focus first on one window and plot some data, then go back to the data generator code and later focus on another window and plot data appropriate to it. Back and forth as needed. I am bewildered by the issue of switching back and forth among the windows, first setting focus on one, and then another.... I have practiced with two windows and two graphs, I can get one (the first one to work) and then later, the second is ignored. I guess the best way to say it is: open a window - plot some data; open a second window plot other data there; then go back to the first window and add some new stuff. etc., etc., shifting focus among the windows as needed. Meanwhile, I try to use a single event loop at the end to quit when I kill a window (or all of them).
Has an example program got such code or can someone help me get started juggling Gadgets, and Creating images and the like... Thanks to the brave souls who have followed thus far. hgc
Multiple windows in an app.
- Zebuddi123
- Enthusiast
- Posts: 796
- Joined: Wed Feb 01, 2012 3:30 pm
- Location: Nottinghamshire UK
- Contact:
Re: Multiple windows in an app.
Hi try the multiple windows example code section
http://purearea.net/pb/CodeArchiv/English.html#21
zebuddi.
http://purearea.net/pb/CodeArchiv/English.html#21
zebuddi.

malleo, caput, bang. Ego, comprehendunt in tempore
Re: Multiple windows in an app.
Hi,
maybe this gives you an idea:
Bernd
maybe this gives you an idea:
Code: Select all
EnableExplicit
Structure WindowStructure
No.i
Button.i
EndStructure
Procedure NewWindow(Map WindowMap.WindowStructure())
Protected.i Win
Win = OpenWindow(#PB_Any, 0, 0, 100, 50, "", #PB_Window_SystemMenu)
If Win
SetWindowTitle(Win, Str(Win))
AddMapElement(WindowMap(), Str(Win))
WindowMap()\No = Win
WindowMap()\Button = ButtonGadget(#PB_Any, 10, 10, 40, 20, "Test")
EndIf
EndProcedure
Define.i MainWindow, Button, Exit, Event, EventWin, TimerCounter, SelWin, i
NewMap WindowMap.WindowStructure()
MainWindow = OpenWindow(#PB_Any, 0, 0, 400, 300, "Main", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If MainWindow
Button = ButtonGadget(#PB_Any, 10, 10, 40, 20, "New")
AddWindowTimer(MainWindow, 1, 1000)
Exit = #False
Repeat
Event = WaitWindowEvent()
EventWin = EventWindow()
Select EventWin
Case MainWindow
Select Event
Case #PB_Event_Timer
If EventTimer() = 1
If MapSize(WindowMap())
TimerCounter + 1
SelWin = TimerCounter % MapSize(WindowMap()) + 1
ResetMap(WindowMap())
For i = 1 To SelWin
NextMapElement(WindowMap())
Next i
SetGadgetText(WindowMap()\Button, Str(TimerCounter))
EndIf
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case Button
NewWindow(WindowMap())
EndSelect
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Default
If FindMapElement(WindowMap(), Str(EventWin))
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case WindowMap()\Button
Debug WindowMap()\No
EndSelect
Case #PB_Event_CloseWindow
CloseWindow(WindowMap()\No)
DeleteMapElement(WindowMap())
EndSelect
EndIf
EndSelect
Until Exit
ForEach WindowMap()
CloseWindow(WindowMap()\No)
Next
EndIf