Hi Rob206,
I started out last week and had problems trying to get my head around the form designer. I wrote this little step by step help example. Hope it helps.
-----------------------------------------------------------------------------------------------
How To create a windows form & program using the Form Designer in PureBasic 5.21 LTS
1) Create a program file example.pb (Location of procedures)
2) Create a new form file - exampleForm0.pbf (Location of windows events handler)
Note - I usually create these in a new folder For simplicity.
3) Add the Gadgets To the form layout. Rename the gadgets If required, this is in the "variable" parameter in the gadget property window. I Usually start out With a couple of Button Gadgets And a couple of Text Gadgets just To create the basic form layout. The example form has Button_0, Button_1, Text_0 And Text_1.
https://dl.dropboxusercontent.com/u/219 ... eForm0.png Form Layout....
4) In the PureBasic IDE Select Form | Switch Code/Design view To view the generated form code. If you used the Default gadget names it should look like the example below:
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 Text_0, Text_1, Button_0, Button_1
Declare Button_0Event(EventType)
Declare Button_1Event(EventType)
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "Example Form ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Text_0 = TextGadget(#PB_Any, 110, 60, 100, 25, "Text Gadget :")
Text_1 = TextGadget(#PB_Any, 120, 140, 350, 25, "Click on Buttons below to trigger events", #PB_Text_Center | #PB_Text_Border)
Button_0 = ButtonGadget(#PB_Any, 130, 250, 100, 25, "Button 0")
Button_1 = ButtonGadget(#PB_Any, 360, 250, 100, 25, "Button 1")
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()
Case Button_0
Button_0Event(EventType())
Case Button_1
Button_1Event(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
5) Copy the code below into the example.pb file. This file holds the procedures For the form.
Code: Select all
XIncludeFile "exampleForm0.pbf" ; Include the first window definition
;
Define Event
;
OpenWindow_0()
Procedure Button_0Event(EventType)
;Debug "Button_0 Event"
MessageRequester("Button Event", "Botton 0 Clicked")
; Add your code here
EndProcedure
Procedure Button_1Event(EventType)
;Debug "Button_1 Event"
MessageRequester("Button Event", "Botton 1 Clicked")
; Add your code here
EndProcedure
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case Window_0
Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close
6) Return To the design view of the exampleForm0.pbf And check that the Event Procedure property in Button_0 And Button_1 have events assigned. This should be "Button_0Event" And "Button_1Event" respectively.
The selector drop down To the right of the 'Event procedure' should have the events listed provided the procedures are in the example.pb file.
7) Compile And Run the example.pb file. If all works well by clicking on the buttons you should get an acknowledgement message box.

Add your code To the Button procedures And start adding new gadgets And procedures.