OK, I am taking the example code from another thread....
http://www.purebasic.fr/english/viewtop ... 22&t=58725
Here it is.....
Main.pb
Code: Select all
XIncludeFile "MainWindow.pbf" ; Include the first window definition
XIncludeFile "DateWindow.pbf" ; Include the second window definition
; 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 Window_0
Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'
Case Window_1
Window_1_Events(Event)
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global Window_0
Global OKButton, CancelButton
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()
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
OpenWindow_0()
Repeat
event = WaitWindowEvent()
Until Window_0_Events(event) = #False
End
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
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
Procedure Window_1_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
OpenWindow_1()
Repeat
event = WaitWindowEvent()
Until Window_1_Events(event) = #False
End
1) It I add EnableExplicit to the top of Main.pb I get the following error about event variable on line 37 of MainWindow.pbf.
I can not see where to define the event variable as defining it in Main.pb still causes the same error.---------------------------
PureBasic
---------------------------
Line 37: With 'EnableExplicit', variables have to be declared: event.
---------------------------
OK
---------------------------
If I define the variable in MainWindow.pbf then as soon and I touch the form (switch between code/form view) the designer removes the define statement.
Where should I define the event variable to please EnableExplicit and allow the designer to keep working with the form without changes when switching between views..
Thank you