Form Designer and Questions

You need some new stunning features ? Tell us here.
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Form Designer and Questions

Post by SniffTheGlove »

Hello, I am having a few issues with the Form Designer. I usually do all my stuff in Console but trying to forms etc with the forms designer.

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
MainWindow.pbf

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
DateWindow.pbf

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
OK, using this code as an example This is what I am having problems with.
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.
---------------------------
PureBasic
---------------------------
Line 37: With 'EnableExplicit', variables have to be declared: event.
---------------------------
OK
---------------------------
I can not see where to define the event variable as defining it in Main.pb still causes the same error.
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
User avatar
Demivec
Addict
Addict
Posts: 4267
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Form Designer and Questions

Post by Demivec »

SniffTheGlove wrote:I can not see where to define the event variable as defining it in Main.pb still causes the same error.
Define it at the beginning of 'Main.pb' before the other files are included.
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Re: Form Designer and Questions

Post by SniffTheGlove »

Demivec wrote:
SniffTheGlove wrote:I can not see where to define the event variable as defining it in Main.pb still causes the same error.
Define it at the beginning of 'Main.pb' before the other files are included.
Thank you. Thank you. So simple.
Post Reply