Author Topic: PureBasic Event-Loop for multiple Windows explained  (Read 2728 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
PureBasic Event-Loop for multiple Windows explained
« on: February 17, 2016, 10:31:26 PM »
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.

Code: [Select]
; 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