Form Designer & multiple windows.
Form Designer & multiple windows.
I had been using PureForm and enjoyed that; but figured it's time to start using the new built in form designer.
The problem I seem to have is that when I follow the help; I end up with two waitwindowevent() loops.
so I have to go in and delete the openwindow & repeat loops out of all form source files before building...
what am I missing?
The problem I seem to have is that when I follow the help; I end up with two waitwindowevent() loops.
so I have to go in and delete the openwindow & repeat loops out of all form source files before building...
what am I missing?
Re: Form Designer & multiple windows.
Disabling the event loop generation in your purebasic preferences should do the trick!
Re: Form Designer & multiple windows.
sadly, it did not..Polo wrote:Disabling the event loop generation in your purebasic preferences should do the trick!
Re: Form Designer & multiple windows.
Here an empty form generates this code, without any event loop.
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
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
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
Re: Form Designer & multiple windows.
Here's what happens for me (pb 5.31 x64)
if I delete the openwindow and loop; it just re-appears later.
if I delete the openwindow and loop; it just re-appears later.
- Teddy Rogers
- User
- Posts: 92
- Joined: Sun Feb 23, 2014 2:05 am
- Location: Australia
- Contact:
Re: Form Designer & multiple windows.
Something like this maybe?
In your .pb file...
...and in the .pbf file...
I just posted some code using the Form Designer, hopefully you may find it helpful...
http://www.purebasic.fr/english/viewtop ... 12&t=60934
Ted.
In your .pb file...
Code: Select all
; The main event loop.
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
MainWindow_Events(Event)
EndSelect
Until Event = #PB_Event_CloseWindow
Code: Select all
Procedure MainWindow_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Checkbox_Lee
Lee_Factor(EventType())
Case #TrackBar_Current
Arcing_Current(EventType())
Case #Button_Calculate
Arcing_Current(EventType())
Case #Combo_Equipment
Arcing_Current(EventType())
Case #Combo_Grounding
Arcing_Current(EventType())
Case #Checkbox_Joules
JoulesToCal(EventType())
Case #Checkbox_Distance
Distance_Factor(EventType())
Case #Combo_Equipment_Type
Equipment_Type(EventType())
Case #TrackBar_Integer
Arcing_Current(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
http://www.purebasic.fr/english/viewtop ... 12&t=60934
Ted.
Re: Form Designer & multiple windows.
Hi jassing. In the properties window, you're only disabling the events procedure. To disable the event loop, you'd have to go to the File > Preferences > Form menu, and disable the Generate event loop option.jassing wrote:Here's what happens for me (pb 5.31 x64)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: Form Designer & multiple windows.
I think it will be better to do the following ,Code: Select all
; The main event loop. Repeat Event = WaitWindowEvent() Select EventWindow() Case MainWindow MainWindow_Events(Event) EndSelect Until Event = #PB_Event_CloseWindow
that would separately handle the window closing event for each window , and yet, you can specify one of the window as the main window.
Code: Select all
Global Window_0, Window_1
Procedure OpenWindow_0(x = 0, y = 0, width = 400, height = 200)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "main window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ProcedureReturn Window_0
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
Procedure OpenWindow_1(x = 0, y = 0, width = 400, height = 200)
Window_1 = OpenWindow(#PB_Any, x, y, width, height, "window1", #PB_Window_SystemMenu)
ProcedureReturn Window_1
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_0()
OpenWindow_1()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
CloseWindow(EventWindow())
If GetActiveWindow() =-1 Or EventWindow() = Window_0
End
EndIf
EndSelect
Select EventWindow()
Case Window_0
Window_0_Events(Event)
Case Window_1
Window_1_Events(Event)
EndSelect
ForEver
Re: Form Designer & multiple windows.
TI994 described what I meant much more efficiently than I
Re: Form Designer & multiple windows.
What do you think?
Code: Select all
CompilerIf Not Defined(IsCloseWindow, #PB_Function) And
Not Defined(IsCloseWindow, #PB_Procedure)
EnableExplicit
CompilerIf Not Defined(PB_Object_Count, #PB_Function) And
Not Defined(PB_Object_Count, #PB_Procedure) And
Not Defined(CountWindow, #PB_Function) And
Not Defined(CountWindow, #PB_Procedure)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
CompilerElse
ImportC ""
CompilerEndIf
PB_Object_Count( Objects )
PB_Window_Objects.l
EndImport
CompilerEndIf
ProcedureDLL IsCloseWindow2( Window = #PB_All)
If Window ! #PB_All
If ((Not IsWindow( EventWindow() )) And EventWindow() = Window )
ProcedureReturn #True
EndIf
Else
If Not PB_Object_Count( PB_Window_Objects )
ProcedureReturn #True
EndIf
EndIf
EndProcedure
ProcedureDLL IsCloseWindow( ) ;Returns TRUE is window close
ProcedureReturn IsCloseWindow2( #PB_All )
EndProcedure
Macro IsCloseWindow( Window = #PB_All) ;Returns TRUE is window close
IsCloseWindow2( Window )
EndMacro
DisableExplicit
CompilerEndIf
CompilerIf Not Defined(WindowClose, #PB_Function) And
Not Defined(WindowClose, #PB_Procedure)
ProcedureDLL WindowClose5(Event,MainWindow =-1,Message =-1,Text$="Вы уверены,"+#CRLF$+"что хотите выйти?",Title$="")
Protected Window = EventWindow()
If Event = #PB_Event_CloseWindow
If IsWindow(Window) And Title$ = ""
Title$ = GetWindowTitle(Window)
EndIf
If MainWindow = Window :Window = -1 :EndIf
;If MainWindow =-1 And Message =-1 :Message = Window :EndIf
Select Message
Case Window
If MessageRequester( Title$, Text$, #PB_MessageRequester_YesNo ) ! #PB_MessageRequester_Yes
ProcedureReturn #False
EndIf
EndSelect
CloseWindow( Window )
If IsCloseWindow( MainWindow )
ProcedureReturn #True
EndIf
EndIf
EndProcedure
ProcedureDLL WindowClose4(Event,MainWindow,Message,Text$)
ProcedureReturn WindowClose5(Event,MainWindow,Message,Text$,"")
EndProcedure
ProcedureDLL WindowClose3(Event,MainWindow,Message)
ProcedureReturn WindowClose4(Event,MainWindow,Message,"Вы уверены,"+#CRLF$+"что хотите выйти?")
EndProcedure
ProcedureDLL WindowClose2(Event,MainWindow)
ProcedureReturn WindowClose3(Event,MainWindow,#PB_All)
EndProcedure
ProcedureDLL WindowClose(Event)
ProcedureReturn WindowClose2(Event,#PB_Any)
EndProcedure
Macro WindowClose(Event,MainWindow =-1,Message =-1,Text="Вы уверены,"+#CRLF$+"что хотите выйти?",Title="") ;Returns TRUE is window close
WindowClose5(Event,MainWindow,Message,Text,Title)
EndMacro
CompilerEndIf
;-----------------------
Global Window_0, Window_1
Procedure OpenWindow_0(x = 0, y = 0, width = 400, height = 200)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "main window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ProcedureReturn Window_0
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
Procedure OpenWindow_1(x = 0, y = 0, width = 400, height = 200)
Window_1 = OpenWindow(#PB_Any, x, y, width, height, "window1", #PB_Window_SystemMenu)
ProcedureReturn Window_1
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_0()
OpenWindow_1()
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case Window_0
Window_0_Events(Event)
Case Window_1
Window_1_Events(Event)
EndSelect
Until WindowClose(Event,Window_0)