Presentation Manager applications are based upon the concept of windows. A window typically represents some object, such as a file or document, a device or a data record, upon which the application will operate. The user interacts with the window to manipulate the object.
A window appears to the user as a rectangular area on the screen, which may be moved and re-sized by the user with either the keyboard or mouse. From an application viewpoint, however, the concept of a window is far more powerful than this. Windows may be of two basic types:
Windows respond to events which are communicated to them by way of messages. Messages may originate from Presentation Manager as a result of user interaction, or from other windows in the system. Messages may be of many different types; Presentation Manager defines a number of message classes, and an application may define its own message classes for communication between its own windows. Messages are routed between windows by Presentation Manager on behalf of the applications, and are discussed in greater detail in Messages.
The basic structure of a Presentation Manager application is therefore that of a group of windows, communicating with one another by way of messages. This is illustrated in Figure "Presentation Manager Application Structure".
The behavior of a window in response to messages directed to it is determined by its window procedure, which determines the processing performed by the window in response to each message it receives. Windows with similar characteristics are grouped into a window class, and share a window procedure.
Note that windows are a finite operating system resource. Under OS/2 Version 1.1 and Version 1.2, the maximum number of windows which could be created in the system was approximately 1200. Under OS/2 Version 1.3 this limit was increased to approximately 10000; this increased limit also applies to OS/2 Version 2.0.
Other Presentation Manager objects such as presentation spaces and device contexts also consume storage for control information. Under OS/2 Version 2.0, the total limit for all graphics resources used by Presentation Manager is approximately 64000.
Note also that when large numbers of windows are created in the system, Presentation Manager uses significant processor resource to handle message routing, clipping etc. Some degradation in overall system performance may therefore be experienced when running with an extremely large number of windows open.
Window Classes
Each window belongs to a window class. The window class determines a number of properties of the window, including its window procedure, which in turn determines the behavior of the window in response to the messages it receives. A window class is registered with Presentation Manager, and may be defined in one of two ways:
A number of window classes, such as the frame window and control windows, are publicly defined by Presentation Manager, and are hence available for use by applications.
Each window within a class is said to be an instance of that class. Multiple windows of the same class may exist in the system at the same time, controlled by the same or different applications.
Window Procedures
Each window in the system has a window procedure, which defines the processing performed by the window for each message it receives. Such processing may include general application logic, I/O operations or communication with other windows. The window procedure is associated with an entire window class rather than an individual instance of the class, and is defined when the class is registered to Presentation Manager.
The window procedure must be provided by the application which registers the window class. Presentation Manager provides its own window procedures for its publicly defined window classes. Applications which register their own window classes must provide a window procedure for each class.
The window procedure is invoked by Presentation Manager on the application's behalf, in response to any message directed to that window, either from Presentation Manager itself or from another window in the system. The window procedure determines the class of the message, and takes appropriate action. Since there are an extremely large number of messages which may be passed to a window, the window procedure need only process those messages which are required to carry out the window's functions; Presentation Manager provides default processing for all system-defined message classes, and application-defined message classes not processed by the window procedure are simply ignored.
Window procedures are re-entrant, and multiple instances of the same window class share the same memory-resident copy of the window procedure. Hence any local data defined by the window procedure is also shared by each window in the class. To allow each window to keep its own separate data areas, Presentation Manager allows an application to define an area known as the window words, which is unique to each individual window, and is maintained with Presentation Manager's own control block for that window. Window words are normally used to store a pointer to a memory object which is dynamically allocated when the window is created, and used to store instance-specific data.