I am trying to understand the Form Designer example in PB5.21 LTS Demo
Have created 2 forms MainWindow.pbf and DateWindow.pbf and 1 code file Main.pb
Main.pb
----------------------------------------------------------------------------------------------------------------------------
Code: Select all
XIncludeFile "MainWindow.pbf" ; Include the first window definition
XIncludeFile "DateWindow.pbf" ; Include the second window definition
;OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
;OpenDateWindow() ; Open the second window
OpenWindow_0()
OpenWindow_1()
; The event procedures, as specified in the 'event procedure' property of each gadget
Procedure OkButtonEvent(EventType)
Debug "OkButton event"
EndProcedure
Procedure CancelButtonEvent(EventType)
Debug "CancelButton event"
EndProcedure
Procedure TrainCalendarEvent(EventType)
Debug "TrainCalendar event"
EndProcedure
; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'
Case DateWindow
Window_1_Events(Event)
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close
---------------------------------------------------------------------------------------------------------------------------------
MainWindow.pbf
Code: Select all
Global Window_0
Global OKButton, CancelButton
Declare OkButtonEvent(EventType)
Declare CancelButtonEvent(EventType)
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
OKButton = ButtonGadget(#PB_Any, 100, 250, 100, 25, "OK")
CancelButton = ButtonGadget(#PB_Any, 360, 250, 100, 25, "Cancel")
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case OKButton
OkButtonEvent(EventType())
Case CancelButton
CancelButtonEvent(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
DateWindow.pbf
Code: Select all
Global Window_1
Global TrainCalendar
Procedure OpenWindow_1(x = 0, y = 0, width = 600, height = 400)
Window_1 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
TrainCalendar = DateGadget(#PB_Any, 180, 120, 200, 30, "")
EndProcedure
When I try to run I get an error message:
Line36: Window_1_Events() is not a function(or not available in demo version), array, list, map or macro
This is in Main.pb
If I comment the line out the program runs but opens both windows with Window_1 over Window_2 (both windows open)
Can someone provide some info on this please? or an example that works.
Thanks