The window concept

Windows are containers for .42f forms.

Creating windows

The windows are created from programs; they define a display context for sub-elements like forms, menus, message and error lines.

A window can contain only one form at a time, but you can display different forms successively in the same window.

A program creates a new window with the OPEN WINDOW instruction, which also defines the window identifier:
OPEN WINDOW mywindow WITH FORM "myform"

Destroying windows

A window is destroyed with the CLOSE WINDOW instruction:
CLOSE WINDOW mywindow

Windows rendering context

When using the text mode (FGLGUI=0), windows are displayed in the character terminal as fixed-size boxes, at a given line/column position, width and height.

When using a graphical desktop front-end (FGLGUI=1), windows are displayed by default as independent resizable native windows with the GDC front-end, or displayed as frames inside a web browser when using the GBC front-end.

Note: A GUI application can run in traditional mode (gui.uiMode="traditional" FGLPROFILE setting), displaying windows as simple static areas inside a real graphical parent window.

When using a mobile device front-end in Native Rendering mode, only one window is visible at the time, because of device platform GUI standards and the limited screen sizes (smartphones). Split views are the exception, as they allow for the display of two windows side by side in a typical list-detail display on tablets.

Default SCREEN window

When a program starts, the runtime system creates a default window named SCREEN.

This default window can be used as a regular window: it can hold a menu and a form.

You typically display the main form of your program in the SCREEN window, by using OPEN FORM + DISPLAY FORM:
MAIN
    -- The SCREEN window exists by default
    ...
    OPEN FORM f_main FROM "customers"
    DISPLAY FORM f_main -- displays in SCREEN
    ...
END MAIN
Tip: If needed, the default SCREEN window can be closed with CLOSE WINDOW SCREEN. However, in most cases, you want to keep this default window and display the main form of the program with OPEN FORM + DISPLAY FORM.

The current window

A program with user interface must always have a current window.

Several windows can be created, but there can be only one current window when using modal dialogs (only one dialog is active at the time, thus only the current window can be active).

Note: When using parallel dialogs, several windows can be active concurrently. Parallel dialogs were introduced to implement split views, for mobile devices.

There is always a current window. The last created window becomes the current window. When the last created window is closed, the previous window in the window stack becomes the current window.

Use the CURRENT WINDOW instruction to make a specific window current, before executing the corresponding dialog that is controlling the window content:
OPEN WINDOW w_customers ...
OPEN WINDOW w_orders ...
...
CURRRENT WINDOW IS w_customers
...
CLOSE WINDOW w_customers
CURRRENT WINDOW IS w_orders
...

However, this practice is not commonly used: A regular Genero program starts with a main window/form and opens new windows in cascade that results in a tree of windows. The last created window is closed to go back to the previous window/form.

Displaying multiple forms in the same window

When there is a current window, it is possible to display several forms successively in that same window.

The previous form is removed automatically by the runtime system when displaying a new form to the window:
OPEN WINDOW mywindow WITH FORM "form1"
INPUT BY NAME ... -- uses form1 elements
...
OPEN FORM f1 FROM "form2"
DISPLAY FORM f1  -- removes "form1" from the window
INPUT BY NAME ... -- uses form2 elements
...

Windows types (TYPE attribute)

By default, a window has no particular type and displays as a regular GUI window on the front-end, to be controlled by a modal dialog instruction. In some situations, you must specify the TYPE of the window, to get a specific rendering and behavior (for example when implementing split-views on mobile front-ends.

Note: Do not confuse the window TYPE attribute with the windowType style attribute, which can be used by specifying a STYLE attribute for the WINDOW.
The window type is defined with the TYPE attribute in the ATTRIBUTES clause of the OPEN WINDOW instruction:
OPEN WINDOW w_cust WITH FORM "f_cust" ATTRIBUTES(TYPE=LEFT)
...
OPEN WINDOW w_pref WITH FORM "f_pref" ATTRIBUTES(TYPE=POPUP)
...

For more details, see Window TYPE attribute.

Window presentation styles

Window decoration and behavior options can be defined with a presentation style.

The window style is identified with the STYLE attribute of the ATTRIBUTES section of OPEN WINDOW, or it can also be specified at form level, with the WINDOWSTYLE form attribute in the LAYOUT of the form definition:
OPEN WINDOW w_cust WITH FORM "f_cust" ATTRIBUTES(STYLE="dialog2")

API for window objects

The ui.Window built-in class can be used to manipulate windows as objects.

The common practice is to get the current form of the window and use it as ui.Form object to manipulate its content.