The window manager maintains a cache of micro presentation spaces for windows on a display screen. The cache is provided for applications that use a large number of windows, and where each window requires a temporary presentation-space device-context pair for a short sequence of output operations. These presentation spaces belong to the system rather than to your application and are allocated only on a temporary basis.
Cached micro presentation spaces are provided by the window system rather than by the GPI. Their use is synchronized with other window activities. For example, you need not associate a cached micro presentation space with the display screen. The window manager does this for you.
Cached micro presentation spaces offer the best system performance because, unlike normal presentation spaces and standard micro presentation spaces, they are not permanently allocated to an application. However, cached micro presentation spaces can be cumbersome to use because all the attributes must be initialized continually.
Use a cached micro presentation space to send output only to a window on the display device. There are three different functions you can use to access a cached micro presentation space, each with its own considerations. These functions are listed in the following table.
┌───────────────┬──────────────────────────────┬───────────────┐ │Function Name │Usage │Closing │ │ │ │Function │ ├───────────────┼──────────────────────────────┼───────────────┤ │WinBeginPaint │Accepts a NULL presentation │WinEndPaint │ │ │space handle for a cached │automatically │ │ │micro presentation space. The │releases the │ │ │presentation space created by │presentation │ │ │this function is already │space, no │ │ │preassociated with the window │matter what │ │ │device context, making this │type. │ │ │the easiest function to use. │ │ │ │Usually this type of creation │ │ │ │is in response to a WM_PAINT │ │ │ │message. │ │ ├───────────────┼──────────────────────────────┼───────────────┤ │WinGetScreenPS │The presentation space │WinReleasePS │ │ │represents the entire display │ │ │ │screen. │ │ │ │Warning: Exercise caution │ │ │ │when using this function as │ │ │ │the graphic output can overlap│ │ │ │individual windows. │ │ ├───────────────┼──────────────────────────────┼───────────────┤ │WinGetPS │The presentation space can │WinReleasePS │ │ │represent the entire desktop, │ │ │ │or any other window. │ │ │ │The presentation space can be │ │ │ │used to process any message, │ │ │ │but it must be returned to the│ │ │ │cache when message processing │ │ │ │is complete. │ │ └───────────────┴──────────────────────────────┴───────────────┘
In general, use a cached micro presentation space to process a single paint message when no presentation space information needs to be remembered between messages. The presentation space must be both obtained and released during the processing of that message. All application information stored in a cached micro presentation space is lost as soon as it is released to the cache.
You must provide a window handle on input to WinBeginPaint and WinGetPS. The resulting presentation space is defined specifically for that window, and cannot be reassociated.
The cached micro presentation space is always:
When you finish using a cached micro presentation space, you do not have to disassociate it from the window device context because WinReleasePS or WinEndPaint performs the disassociation. This makes the cached micro presentation space available for use in other windows. The presentation space itself cannot be deleted.
Cached micro presentation spaces are used serially. The next time you need a cached presentation space, access a new one using the appropriate function. Each time you get a cached micro presentation space, graphics attributes are reset to their default values.