How to open and reopen a window from a first window?
Re: How to open and reopen a window from a first window?
Thanks TI-994A,
This way would mean I need to put all the coding for the forms in one place, the main form. That complicates the maintenance of the application. My goal was to use BoekhoudingPanelApp.pbi as the coding page for his BoekhoudingPanelApp.pbf. The main code page is elsewhere. As there are other forms too. And many to come.
Greetings from Belgium
Rudi
This way would mean I need to put all the coding for the forms in one place, the main form. That complicates the maintenance of the application. My goal was to use BoekhoudingPanelApp.pbi as the coding page for his BoekhoudingPanelApp.pbf. The main code page is elsewhere. As there are other forms too. And many to come.
Greetings from Belgium
Rudi
Re: How to open and reopen a window from a first window?
RBart wrote: Sat Dec 27, 2025 7:43 am...My goal was to use BoekhoudingPanelApp.pbi as the coding page for his BoekhoudingPanelApp.pbf. The main code page is elsewhere. As there are other forms too. And many to come.
This can easily be achieved by some creative structuring.
BoekhoudingPanelApp.pbf (form file unchanged)
Code: Select all
;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;
Enumeration FormWindow
#PanelApp
EndEnumeration
Enumeration FormGadget
#Tree_0
#Panel_0
EndEnumeration
Enumeration FormMenu
#MenuItem_3
#MenuItem_4
EndEnumeration
Procedure OpenPanelApp(x = 0, y = 0, width = 1000, height = 600)
OpenWindow(#PanelApp, x, y, width, height, "Boekhouding", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
CreateMenu(0, WindowID(#PanelApp))
MenuTitle("Bestand")
MenuItem(#MenuItem_3, "Open Window 3")
MenuTitle("Bewerken")
MenuItem(#MenuItem_4, "Close Window")
TreeGadget(#Tree_0, 0, 0, 190, 666)
PanelGadget(#Panel_0, 190, 0, 1130, 666)
AddGadgetItem(#Panel_0, -1, "Klanten")
AddGadgetItem(#Panel_0, -1, "Offertes")
CloseGadgetList()
EndProcedure
BoekhoudingPanelApp.pbi (include-file to exclusively handle the form file)
Code: Select all
Declare main_MenuPanelApp_window_handler()
Declare main_MenuPanelApp_menu4_handler()
Declare main_MenuPanelApp_menu3_handler()
XIncludeFile "BoekhoudingPanelApp.pbf"
Procedure main_MenuPanelApp_window_handler()
PostEvent(#PB_Event_CloseWindow)
EndProcedure
Procedure main_MenuPanelApp_menu3_handler()
open_window_3()
EndProcedure
Procedure main_MenuPanelApp_menu4_handler()
PostEvent(#PB_Event_CloseWindow)
EndProcedure
; ...create all other object-event callbacks here
Procedure openMainPanelApp()
OpenPanelApp()
BindEvent(#PB_Event_CloseWindow, @main_MenuPanelApp_window_handler(), #PanelApp)
BindMenuEvent(0, #MenuItem_3, @main_MenuPanelApp_menu3_handler())
BindMenuEvent(0, #MenuItem_4, @main_MenuPanelApp_menu4_handler())
; ...bind all other object events for BoekhoudingPanelApp.pbf here
EndProcedure
Window3.pb (window3 file unchanged)
Code: Select all
Enumeration FormWindow
#window3
EndEnumeration
Enumeration FormGadget
#w3_button
EndEnumeration
Procedure w3_button_handler()
MessageRequester("Window 3", "Window 3 Button clicked!", #PB_MessageRequester_Ok)
EndProcedure
Procedure w3_close_window_handler()
CloseWindow(#window3)
EndProcedure
Procedure open_window_3()
winFlags = #PB_Window_SystemMenu | #PB_Window_WindowCentered
OpenWindow(#window3, #PB_Ignore, #PB_Ignore, 400, 200, "Window 3", winFlags, #PanelApp)
ButtonGadget(#w3_button, 10, 160, 380, 30, "Window 3 Button")
BindEvent(#PB_Event_CloseWindow, @w3_close_window_handler(), #window3)
BindGadgetEvent(#w3_button, @w3_button_handler())
EndProcedure
main.pb (main code file to stitch them all together - just run this)
Code: Select all
; this must be declared here as it is called from BoekhoudingPanelApp.pbi
Declare open_window_3()
XIncludeFile "BoekhoudingPanelApp.pbi"
XIncludeFile "Window3.pb"
openMainPanelApp()
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Here, the BoekhoudingPanelApp.pbi code file already calls its corresponding form file, BoekhoudingPanelApp.pbf, so the main app just needs to include the .pbi file along with the Window3.pb file.
With this approach, the form files and their corresponding handler files could be cleanly and clearly segregated like independent components.
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: How to open and reopen a window from a first window?
Thanks again TI-994A
I will try to implement this approach in my application. Almost there to build a basic skeleton for building multiple forms based applications with PureBasic around.
Would be nice to have standard inside PureBasic. Like you get the source code of the ".pbi" when you switch between design and code. Where you can select the object of the ".pbf" you want to write code to. And basic handling taking care of, like open and close forms, modal, popup, normal. Would be faster for developing and easier getting into PureBasic. Maybe in some future PureBasic version...
Greetings from Belgium
Rudi
I will try to implement this approach in my application. Almost there to build a basic skeleton for building multiple forms based applications with PureBasic around.
Would be nice to have standard inside PureBasic. Like you get the source code of the ".pbi" when you switch between design and code. Where you can select the object of the ".pbf" you want to write code to. And basic handling taking care of, like open and close forms, modal, popup, normal. Would be faster for developing and easier getting into PureBasic. Maybe in some future PureBasic version...
Greetings from Belgium
Rudi
Re: How to open and reopen a window from a first window?
Attention: advertisement!
If you want to create multiple windows (dialog boxes) and find that writing the entire event management yourself is too much work,
take a look at my EventDesigner (see signature). All you have to do is disable #PB_Any and "Generate event procedure" in FormDesigner and assign a separate window constant for each window (Main, Dialog1, Dialog2, Properties, etc.).
The program will do the rest, like call the event procedure over bind event.
If you want to create multiple windows (dialog boxes) and find that writing the entire event management yourself is too much work,
take a look at my EventDesigner (see signature). All you have to do is disable #PB_Any and "Generate event procedure" in FormDesigner and assign a separate window constant for each window (Main, Dialog1, Dialog2, Properties, etc.).
The program will do the rest, like call the event procedure over bind event.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to open and reopen a window from a first window?
Hi mk-soft
It only confirms the need for such a feature wich is basic in most application building. Nice work but maybe better to have it in the ide directly. I don't know if there is a way to extend the ide itself. I guess not, since it's not open source. Maybe there's a way for add-ons?
I don't mind the extra work at first to get into PureBasic. I am retired. I like Purebasic, a lot, for other reasons. But many others will leave purebasic faster, after checking it out, because of the lack of these basic features. It's almost 2026. The world has changed a lot.
I believe there's still a place in it for PureBasic.
I also like Linux and open source. I don't like subscriptions based software in general. Although difficult to avoid completely. Also like Android you see..
Greetings from Belgium
Rudi
It only confirms the need for such a feature wich is basic in most application building. Nice work but maybe better to have it in the ide directly. I don't know if there is a way to extend the ide itself. I guess not, since it's not open source. Maybe there's a way for add-ons?
I don't mind the extra work at first to get into PureBasic. I am retired. I like Purebasic, a lot, for other reasons. But many others will leave purebasic faster, after checking it out, because of the lack of these basic features. It's almost 2026. The world has changed a lot.
I believe there's still a place in it for PureBasic.
I also like Linux and open source. I don't like subscriptions based software in general. Although difficult to avoid completely. Also like Android you see..
Greetings from Belgium
Rudi
Re: How to open and reopen a window from a first window?
Not true.
Hundreds of thousands of young coders jump to their keyboards using all sorts of complicated languages. Where they ultimately land depends on many factors, but ease of form building is not the deciding factor.
Children learn to bicycle with training wheels, but I rarely see adults use them?
I admit mastering event loops is initially tricky, but add multithreading and it becomes an advanced topic. Learn it as soon as you can with the many fine examples from mk-soft and infratec and TI-994A.
Hundreds of thousands of young coders jump to their keyboards using all sorts of complicated languages. Where they ultimately land depends on many factors, but ease of form building is not the deciding factor.
Children learn to bicycle with training wheels, but I rarely see adults use them?
I admit mastering event loops is initially tricky, but add multithreading and it becomes an advanced topic. Learn it as soon as you can with the many fine examples from mk-soft and infratec and TI-994A.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: How to open and reopen a window from a first window?
The PureBasic IDE is open source ...
Link: https://github.com/fantaisie-software/purebasic
In addition, you can also add your own external tools in the IDE
Menu -> Tools -> Configure Tools
Link: https://github.com/fantaisie-software/purebasic
In addition, you can also add your own external tools in the IDE
Menu -> Tools -> Configure Tools
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to open and reopen a window from a first window?
Thanks for the information.
Anyway. I will look into the project on Github later. Still need to get the hang of PureBasic first. Don't know where I end up neither. And I'm almost 62.
I come from VB and VBA, used it for 29 years on the job, not really a choice. It was the part of the job I liked.
Have a nice new year,
Greetings from Belgium
Rudi
Anyway. I will look into the project on Github later. Still need to get the hang of PureBasic first. Don't know where I end up neither. And I'm almost 62.
I come from VB and VBA, used it for 29 years on the job, not really a choice. It was the part of the job I liked.
Have a nice new year,
Greetings from Belgium
Rudi
Re: How to open and reopen a window from a first window?
Has nothing to do with age. I'm already one of the old ones (60).
And the (new) customers ask if anyone is still familiar with the old controllers.
You are not as fast as you used to be, but you don't get rid of the experience.
And the (new) customers ask if anyone is still familiar with the old controllers.
You are not as fast as you used to be, but you don't get rid of the experience.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to open and reopen a window from a first window?
Hi,
Happy New year.
I got the application working with different forms. The forms created with the form designer have two files now (see code below).
I had to do some changes to get it all working. I have put some comments in the code.
The generated form:
The .pbi that goes with it:
Thanks for all the help to get so far.
Greetings from Belgium
Rudi
Happy New year.
I got the application working with different forms. The forms created with the form designer have two files now (see code below).
I had to do some changes to get it all working. I have put some comments in the code.
The generated form:
Code: Select all
;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;
Enumeration FormWindow
;#PanelApp Had to be enummerated on the main form because the main form disappeared.
EndEnumeration
Enumeration FormGadget
#Tree_0
#Panel_0
EndEnumeration
Enumeration FormMenu
#MenuItem_2
#MenuItem_4
#MenuItem_5
EndEnumeration
Procedure OpenPanelApp(x = 0, y = 0, width = 1170, height = 650)
OpenWindow(#PanelApp, x, y, width, height, "Boekhouding", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
CreateMenu(#MenuPanel, WindowID(#PanelApp)) ; Had to change this from CreateMenu(0, WindowID(#PanelApp)) Because the Menu on the main form disappeared.
MenuTitle("Bestand")
MenuItem(#MenuItem_2, "MenuItem2")
MenuItem(#MenuItem_4, "MenuItem4")
MenuItem(#MenuItem_5, "MenuItem5")
MenuTitle("Bewerken")
MenuTitle("MenuTitle")
TreeGadget(#Tree_0, 0, 0, 190, 666)
PanelGadget(#Panel_0, 190, 0, 1130, 666)
AddGadgetItem(#Panel_0, -1, "Klanten")
AddGadgetItem(#Panel_0, -1, "Offertes")
CloseGadgetList()
EndProcedure
Code: Select all
;=========================================================
;Procedures for the form design of BoekhoudingPanelApp.pbf
;=========================================================
;Declare the procedures further down to tell the compiler
;=========================================================
Declare openMainPanelApp()
;================================================
;procedures to connect with main form or boekhouding.pb
;================================================
Procedure main_MenuPanelApp_handler()
openMainPanelApp() ; will start up the form
EndProcedure
BindMenuEvent(#MainMenu,#MenuPanelApp,@main_MenuPanelApp_handler()) ; !!Connect the mainmenu!! from boekhouding.pb alias main. Executes the procedure "main_MenuPanelApp_handler()" above here.
;=================================================
; BoekhoudingPanelApp.pbi itself
;=================================================
XIncludeFile "BoekhoudingPanelApp.pbf" ;include the form design in the application
;Events procedures (must be Bond under the openMainPanelApp()
;=================================================
Procedure main_MenuPanelApp_menu4_handler()
CloseWindow(#PanelApp)
EndProcedure
Procedure PanelApp_close_window_handler()
CloseWindow(#PanelApp)
EndProcedure
; ...create all other object-event callbacks here
;==================================================
;Programming the form
;=====================
Procedure openMainPanelApp()
;!!!TO GET THIS WORKING WITH THE FORM DESIGNER
;!!!#PB_Any must be unchecked! The function to open the form will always be "Open" + the name of the variable of the form + () (in this case OpenPanelApp()).
;!!!Uncheck "Generate events procedures" too (Can be set under File -> preferences so you don't need to change this every time)
;!!!EVERY TIME AFTER CREATION of the form switch code/ design view and comment the constant generated for the form
;!!!Enumeration FormWindow
;!!! ;#PanelApp
;!!!EndEnumeration
;!!!The constant #PanelApp (form) must be Enumerated on the main form
;!!!Give the menu on the created form a constant name in this case: #MenuPanel (see below BindMenuEvent(#MenuPanel...) and put in List of Enumeration of Menubar on the main form.
OpenPanelApp() ;Calls the procedure that opens the form designed on BoekhoudingPanelApp.pbf
;Binding the events:
BindEvent(#PB_Event_CloseWindow, @PanelApp_close_window_handler(), #PanelApp) ;BindEvent(#PB_Event_CloseWindow, @main_MenuPanelApp_handler(), #PanelApp)
;BindMenuEvent(0, #MenuItem_3, @main_MenuPanelApp_menu3_handler())
BindMenuEvent(#MenuPanel, #MenuItem_4, @main_MenuPanelApp_menu4_handler())
; ...bind all other object events for BoekhoudingPanelApp.pbf here
EndProcedure
Greetings from Belgium
Rudi
Re: How to open and reopen a window from a first window?
If you work with multiple forms, you must assign unique names to all Window, Gadget, Menu constants (variables) in the FormDesigner.
Then there are no conflicts.
(Or you take my EventDesigner)
Then there are no conflicts.
(Or you take my EventDesigner)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to open and reopen a window from a first window?
I had the enummeration wrong too.mk-soft wrote: Thu Jan 01, 2026 7:04 pm If you work with multiple forms, you must assign unique names to all Window, Gadget, Menu constants (variables) in the FormDesigner.
Then there are no conflicts.
(Or you take my EventDesigner)![]()
On the main windows were
Enummeration Windows
...
The forms use
Enummeration FormWindow
...
However:
I didn't find a way to change the constant or variable of the menu.
Code: Select all
Procedure OpenfrmFactuurOpmaken(x = 0, y = 0, width = 600, height = 400)
OpenWindow(#frmFactuurOpmaken, x, y, width, height, "Factuur opmaken", #PB_Window_SystemMenu)
CreateMenu(0, WindowID(#frmFactuurOpmaken))
MenuTitle("MenuTitle")
MenuItem(#MenuItem_2, "MenuItem2")
EndProcedureDoes your eventdesigner work on Linux?
Why not improve on the IDE itself? It's written in PureBasic, not? Multiple forms design is a feature in demand, or am I that wrong? Even saw a whole project like PureVision. Can't use that.
Last edited by RBart on Fri Jan 02, 2026 9:24 am, edited 1 time in total.
Re: How to open and reopen a window from a first window?
Select added Menu Item and change at right side properties
- Constant
- Name
Unfortunately, FormDesigner does not have the option to create multiple menus and has the following in CreateMenu(0, ...)
The same applies to the status bar.
I solved this problem with my Tool EventDesigner by correcting the form code and creating a common GuiCommonFile.pb from several forms.
- Constant
- Name
Unfortunately, FormDesigner does not have the option to create multiple menus and has the following in CreateMenu(0, ...)
The same applies to the status bar.
I solved this problem with my Tool EventDesigner by correcting the form code and creating a common GuiCommonFile.pb from several forms.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to open and reopen a window from a first window?
Not much use that you can change this. Every time you switch to code the change is gone. Can this be changed in the behaviour of the formdesigner?Select added Menu Item and change at right side properties
- Constant
- Name
Re: How to open and reopen a window from a first window?
Here it goes.
The value in the properties is only taken over at Enter or when changing the field
The value in the properties is only taken over at Enter or when changing the field
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive


