• Welcome to Jose's Read Only Forum 2023.

PureBasic Event-Loop for multiple Windows explained

Started by Theo Gottwald, February 17, 2016, 10:31:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

Creating a Application with multiple Forms is not "easy going" in PureBasic.
Not like in Firefly or in Phoenix, just drag and drop.

Instead you have to handcode the event-loop.

Here is an example for 2 Forms.
It can easily be customized for many more forms.

; Main

; OpenConsole() + PrintN("") -> very good for Debug-Printing

: Opens the Form and generates all the controls of the Main -Form

; Set all the controls of Mainform to their default state

; Here is the Main-Event-Loop
   ; Get the Event
  Event = WaitWindowEvent()   

   ; Get the Windowhandle of the window for which the event was

    Select Fes
      Case FRM_Main
         ; This Procedure is for the Events of the Main-Window-Form
      Case FRM_Set
        ; This Procedure ist for the Events of the Settings-Form

  ; If the Settings-Form is closed, the Application should NOT END.
  ; If the Main-Form is closed the application should end. This happens here below.
   If Event = #PB_Event_CloseWindow ; Beenden, wenn eines der Fenster geschlossen wird.
     If Fes=FRM_Main

; The "Break" from above comes here .... if the Main-Form is closed