Progress
Language Tutorial
for Character


Using Multi-window Interfaces

The scope of this tutorial is to provide a basic, but thorough, understanding of the interface components and language statements needed to write single-window applications. Still, Progress supports a wide range of advanced programming options to let you create multi-window applications in graphical environments. For more information on these advanced techniques, see the Progress Programming Handbook for more information.

What follows in the next few sections is a quick introduction to very basic window concepts. The purpose is to contrast these concepts and techniques with those that apply to field-level widgets and windows.

Window Attributes

The design of multi-window applications is outside the scope of this tutorial, but the tutorial does show you how to create a second window. When working with windows, three attributes are important to know about:

Creating a New Window

You can create a new window with the CREATE Widget statement. The window inherits the look and feel of the environment in which you create it. The CREATE Widget statement allows you to create windows dynamically within a program. This is the syntax for creating a window.

SYNTAX
CREATE WINDOW handle-variable
  [ ASSIGN attribute = value [ attribute = value ] ... ] 

For the most part, you need to assign attributes to window widgets as you create them, as in the following example:

DEFINE VARIABLE Mywindow AS WIDGET-HANDLE.
        .
        .
        .
CREATE WINDOW  Mywindow
    ASSIGN MESSAGE-AREA = No STATUS-AREA = No. 

Referencing Windows

Progress defines a window widget as the workspace of your application. Each time you start a Progress session, it automatically creates a default window. In graphical environments, you start with the default window, but you can create other, overlapping windows dynamically within your application.

When you are working with the default window, you reference it by using the DEFAULT-WINDOW system handle. This system handle holds the widget handle of the default window.

When you are working with more than one window, the CURRENT-WINDOW system handle holds the widget handle of the window that has input focus. For single-window applications, DEFAULT-WINDOW and CURRENT-WINDOW are equal, but referring to DEFAULT-WINDOW is a little clearer.

When you have two or more windows, only the current window has input focus.

Finally, to clarify ambiguous references to widgets in different windows, use the IN WINDOW syntax. For example, an application may have several Delete buttons. The following code fragment uses the IN WINDOW syntax to specify the Delete button in the window, Mywindow:

WAIT-FOR CHOOSE OF btn-Delete IN WINDOW Mywindow. 

Window Events

When you are working with windows, there are four event functions that you’ll frequently use to add functionality to the window.

Defining Window Families

When you design an application that uses multiple windows, you can create useful interactions between the windows by parenting windows to other windows. A group of windows that are parented to one another is called a window family. By defining a window family, you allow yourself the opportunity to manage the windows individually or as a group.

The window parented by the window system is the root window. A parent window is a window that parents another window, and a window parented by another window is a child window. Windows that are parented by the same window are sibling windows. A child window can only be parented by one window at a time.

Each window in a window family functions much the same as an individual window. That is, you can individually move, resize, and interact with a member of a window family like an individual window. However, window families share a number of additional properties that make them convenient for both applications and users to manage. For example, window families make it easier for you to coordinate:

The relationships created by window families can be very useful because you can use them to manage your interface more effectively, and with less code. If you define a window family, you can control all the windows for an application as a single set, or as individual windows. For example, you can ensure that Progress closes all windows in an application when the user closes the root window. You can ensure that when a parent window is minimized, all the descendant windows of that window are also closed. This is useful in applications that use persistent procedures.

To define a window family, set the PARENT attribute of the child window to the widget handle of the parent window, as shown below. In lt-12-04.p, window child1 is a child window of window parent1, and window grandchild1 is a child window of window child1. You can use this example to investigate the minimizing properties of window families:

lt-12-04.p
DEFINE VARIABLE parent1 AS HANDLE.
DEFINE VARIABLE child1 AS HANDLE.
DEFINE VARIABLE grandchild1 AS HANDLE.
DEFINE BUTTON btn-Exit LABEL "Exit".

CREATE WINDOW parent1 
 ASSIGN TITLE =  "Parent Window"
       HEIGHT-CHARS = 5
       WIDTH-CHARS = 35.

CREATE WINDOW child1 
 ASSIGN TITLE =  "Child Window"
       HEIGHT-CHARS = 5
       WIDTH-CHARS = 35
       PARENT = parent1.

CREATE WINDOW grandchild1 
 ASSIGN TITLE =  "Grandchild Window"
       HEIGHT-CHARS = 5
       WIDTH-CHARS = 35
       PARENT = child1.

DISPLAY btn-Exit WITH FRAME framea.
ENABLE ALL WITH FRAME framea.
VIEW parent1.
VIEW child1.
VIEW grandchild1.
WAIT-FOR CHOOSE OF btn-Exit. 

When you run lt-12-04.p, Progress displays the following screen:

;

For a discussion of windows and window programming techniques, see the Progress Programming Handbook .


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095