Page 1 of 1
The form designers way of doing things.
Posted: Wed Mar 29, 2023 8:01 am
by Amon
This is the code in my form.
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 MainWindow
Global Button_Quit
Declare ResizeGadgetsMainWindow()
Declare event_btn_quit(EventType)
Declare MainWindowEvent(Event, Window)
Procedure OpenMainWindow(x = 0, y = 0, width = 840, height = 520)
MainWindow = OpenWindow(#PB_Any, x, y, width, height, "Amons Utilities", #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
Button_Quit = ButtonGadget(#PB_Any, 720, 480, 100, 25, "Quit")
EndProcedure
Procedure ResizeGadgetsMainWindow()
Protected FormWindowWidth, FormWindowHeight
FormWindowWidth = WindowWidth(MainWindow)
FormWindowHeight = WindowHeight(MainWindow)
ResizeGadget(Button_Quit, 720, 480, 100, FormWindowHeight - 495)
EndProcedure
Procedure MainWindow_Events(event)
Select event
Case #PB_Event_SizeWindow
ResizeGadgetsMainWindow()
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case Button_Quit
event_btn_quit(EventType())
EndSelect
Default
MainWindowEvent(event,MainWindow)
EndSelect
ProcedureReturn #True
EndProcedure
This is the code in my main pb file:
Code: Select all
XIncludeFile "UtilityForm.pbf" ; Include the first window definition
OpenMainWindow()
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
I'm getting 'declared but not defined' errors. Ok. I'm trying my best to follow tutorials and threads on this forum but all of them show a different way of everything and nothing works.
What's going on here?
Re: The form designers way of doing things.
Posted: Wed Mar 29, 2023 8:21 am
by Marc56us
1. It is better to put the main loop in the main code.
2. Don't forget #PB_Window_SizeGadget if you want to resize.
3. Anchor Quit button bottom right (il you want it to follow resize à bottom right)
UtilityForm.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 MainWindow
Global Button_Quit
Declare ResizeGadgetsMainWindow()
Declare MainWindowEvent(Event, Window)
Procedure OpenMainWindow(x = 0, y = 0, width = 840, height = 520)
MainWindow = OpenWindow(#PB_Any, x, y, width, height, "Amons Utilities", #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
Button_Quit = ButtonGadget(#PB_Any, 720, 480, 100, 25, "Quit")
EndProcedure
Procedure ResizeGadgetsMainWindow()
Protected FormWindowWidth, FormWindowHeight
FormWindowWidth = WindowWidth(MainWindow)
FormWindowHeight = WindowHeight(MainWindow)
ResizeGadget(Button_Quit, FormWindowWidth - 120, FormWindowHeight - 40, 100, 25)
EndProcedure
UtilityForm.pb
Code: Select all
EnableExplicit
XIncludeFile "UtilityForm.pbf" ; Include the first window definition
OpenMainWindow()
Repeat
Select WaitWindowEvent()
Case #PB_Event_SizeWindow
ResizeGadgetsMainWindow()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case Button_Quit
End
EndSelect
Default
EndSelect
ForEver
End
Re: The form designers way of doing things.
Posted: Wed Mar 29, 2023 9:11 am
by Amon
ok. I pasted your code in the main file and it gives me the following error.
The procedure 'event_btn_quit()' has been declared but not defined.
These are the errors that have been doing my head in.
I want to add that in the 'Layout' section of the panel in the form designer in 'Event Procedure' I put 'event_btn_quit' and in the same place for the main window i put 'MainWindowEvent'.
Is it correct to do this?
Re: The form designers way of doing things.
Posted: Wed Mar 29, 2023 9:28 am
by Marc56us
Sorry, I forgot to specify: you have to disable the automatic generation of the event procedure
File > Preferences > Form > [ ] Generate event procedure (uncheck)
Then paste my code into pbf source
Form > Switch Code/Design View
(erase all existing text and paste mine, then switch again)
Form > Switch Code/Design View
Re: The form designers way of doing things.
Posted: Wed Mar 29, 2023 3:25 pm
by Amon
That worked, thank you.
Re: The form designers way of doing things.
Posted: Wed Apr 19, 2023 7:15 am
by stolzy
I have also been struggling with the form designer.
There seems to be a lack of tutorials/information on how it works now. I've got myself very confused by watching tutorials that are not appropriate to the current interation of the forms designer or simply don't work with the current FD.
Maybe some kind soul could create or point to some good resources.
Re: The form designers way of doing things.
Posted: Wed Apr 19, 2023 12:39 pm
by mk-soft
The FormDesigner has a weakness, but it works.
I don't like the default variables (#PB_Any) and prefer to use the constants.
Many people write the event handling themselves instead of using the generated one.
What I miss is the fully automatic creation of all required event procedures like in VB6.
But I have achieved this with my own tool, which can also manage several windows. (See signature EventDesigner)
Re: The form designers way of doing things.
Posted: Thu Apr 20, 2023 12:13 pm
by TI-994A
stolzy wrote: Wed Apr 19, 2023 7:15 amI have also been struggling with the form designer...
... Maybe some kind soul could create or point to some good resources.
Perhaps this might help:
>
PureBasic Form Designer Tutorial 2022
Re: The form designers way of doing things.
Posted: Thu Apr 20, 2023 12:42 pm
by Caronte3D
If you can spend some money, IceDesign is a very good replacement for the in-house form designer, and by buying it we support the programmer, member of this community.
Worth a look:
viewtopic.php?t=74711&hilit=icedesign
PS: I don't have any relation with the developer, it's only my opinion as user of this tool.
Re: The form designers way of doing things.
Posted: Thu Apr 20, 2023 1:41 pm
by stolzy
TI-994A wrote: Thu Apr 20, 2023 12:13 pm
stolzy wrote: Wed Apr 19, 2023 7:15 amI have also been struggling with the form designer...
... Maybe some kind soul could create or point to some good resources.
Perhaps this might help:
>
PureBasic Form Designer Tutorial 2022
I've been through that a number of times, but it would still be nice to have some proper documentation. there are issues between the version depicted in the video and other online resources. Took me some time to work out that the way the Forms designer works had changed significantly between versions.
Re: The form designers way of doing things.
Posted: Thu Apr 20, 2023 1:49 pm
by Marc56us
Took me some time to work out that the way the Forms designer works had changed significantly between versions.

This new Form Designer appeared 11 years ago and has not changed since (except for some bug fixes).

In any case, the documentation provided with a software is the reference compared to the online documentation.

F1 Key First
History
5th November
2012 : Version 5.00
- Added: Brand new Form Designer, for Windows, Linux and OS X
Re: The form designers way of doing things.
Posted: Sat Apr 29, 2023 4:52 am
by Amon
Caronte3D wrote: Thu Apr 20, 2023 12:42 pm
If you can spend some money, IceDesign is a very good replacement for the in-house form designer, and by buying it we support the programmer, member of this community.
Worth a look:
viewtopic.php?t=74711&hilit=icedesign
PS: I don't have any relation with the developer, it's only my opinion as user of this tool.
Hey thanks for that. I just tried it and it's a million times more efficient and understandable than the default Form Designer. It's a definite purchase.