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), WINDOW objects are displayed in the character terminal as fixed-size boxes, at a given line/column position, width and height.

In graphical mode, all WINDOW objects are displayed in a single resizable desktop window container or web browser frame. The rendering of the window container can be customized. For more details, see Containers for program windows.

A GUI application can run in traditional mode (gui.uiMode="traditional" FGLPROFILE setting), displaying windows as fixed static frames inside the real graphical parent window.

When using a mobile device front-end, only one window is visible at the time, because of device platform GUI standards and the limited screen sizes (smartphones).

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 window with ui.Window.getCurrent(), get the current displayed form with the getForm() window object method, and use it as ui.Form object to manipulate its content.

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.

Programs typically display their main form 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

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.

Before invoking methods such as ui.Window.getCurrent() to get the default screen window object, and no other user interface instruction was used for this window, execute CURRENT WINDOW IS SCREEN before calling the ui.Window methods.

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).

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
...

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")