Main structure
Your application using the Form Designer should be structured this way:
Code: Select all
- one main file, which includes all form .pbf files (eg main.pb)
- window 1 Purebasic Form file (eg form.pbf)
- window 1 event Purebasic file (eg form.pb)
- window 2 Purebasic Form file (eg form2.pbf)
- window 2 event Purebasic file (eg form2.pb)
You need to assign a Purebasic file that will link the .pbf and handle its event. For that, select the window in the Form Designer, and select the .pb file that will contain the event procedures related to that window and its gadgets.

The .pbf file will now include the .pb file you have selected.
Create the event procedure
Open the .pb file, and create the procedures you will need for handling you events. You should follow the example below:
Assign the event procedure to a gadgetProcedure EventButtonOK(EventGadget, EventType)
MessageRequester("Form", "OK has been clicked on.")
EndProcedure
To assign a procedure which will be called once an event is fired on a gadget, select the gadget, and use the dropdown menu to select the procedure contained in the .pb file.

EventButtonOK() will now be called everytime an event occurs on the gadget.
Create the main Purebasic file
Your main file (main.pb in this example) will now need to include form.pbf (which itself includes form.pb). A simple example would look like this:
Code: Select all
IncludeFile "form.pbf"
; Open the window and the gadgets/menu/toolbar created in form.pbf
InitWindow_0()
Repeat
Event = WaitWindowEvent()
;Call the procedure generated in form.pbf, which handles all events for the window. It will call EventButtonOK().
Window_0_Events(Event)
Until Event = #PB_Event_CloseWindow
End