The form designers way of doing things.

You need some new stunning features ? Tell us here.
User avatar
Amon
User
User
Posts: 16
Joined: Wed Feb 18, 2004 1:24 am
Location: Shropshire, United Kingdom
Contact:

The form designers way of doing things.

Post 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?
This is my sig. By reading this or moving your mouse or eyes in to this box to read what is written you will have automatically been haxored to oblivion by a ver dangerous virus I programmed when computers never existed.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: The form designers way of doing things.

Post 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
User avatar
Amon
User
User
Posts: 16
Joined: Wed Feb 18, 2004 1:24 am
Location: Shropshire, United Kingdom
Contact:

Re: The form designers way of doing things.

Post 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?
This is my sig. By reading this or moving your mouse or eyes in to this box to read what is written you will have automatically been haxored to oblivion by a ver dangerous virus I programmed when computers never existed.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: The form designers way of doing things.

Post 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
User avatar
Amon
User
User
Posts: 16
Joined: Wed Feb 18, 2004 1:24 am
Location: Shropshire, United Kingdom
Contact:

Re: The form designers way of doing things.

Post by Amon »

That worked, thank you.
This is my sig. By reading this or moving your mouse or eyes in to this box to read what is written you will have automatically been haxored to oblivion by a ver dangerous virus I programmed when computers never existed.
stolzy
New User
New User
Posts: 5
Joined: Sun Apr 16, 2023 7:47 am

Re: The form designers way of doing things.

Post 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.
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: The form designers way of doing things.

Post 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)
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
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: The form designers way of doing things.

Post 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
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 :D
User avatar
Caronte3D
Addict
Addict
Posts: 1025
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: The form designers way of doing things.

Post 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.
stolzy
New User
New User
Posts: 5
Joined: Sun Apr 16, 2023 7:47 am

Re: The form designers way of doing things.

Post 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.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: The form designers way of doing things.

Post 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).
:arrow: In any case, the documentation provided with a software is the reference compared to the online documentation.
:idea: F1 Key First

History
5th November 2012 : Version 5.00
- Added: Brand new Form Designer, for Windows, Linux and OS X
User avatar
Amon
User
User
Posts: 16
Joined: Wed Feb 18, 2004 1:24 am
Location: Shropshire, United Kingdom
Contact:

Re: The form designers way of doing things.

Post 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.
This is my sig. By reading this or moving your mouse or eyes in to this box to read what is written you will have automatically been haxored to oblivion by a ver dangerous virus I programmed when computers never existed.
Post Reply