## Presentation Device Driver Reference for OS/2

[prev][next][parent][TOC]

### Opening and Closing DCs

The open and close transaction sequences are symmetrical. [Artwork not shown]

Device contexts are opened in response to an application or process calling the DevOpenDC API function. On receiving this call, the graphics engine ( PMGRE.DLL) loads the presentation driver, if it is not already present and able to support the device context, and issues a series of calls to the OS2 _PM_DRV_ENABLE entry point.

Initially, when the presentation driver has not been enabled for use by the calling application or process, the driver receives the Open Transaction series of calls. When the driver has been enabled for an application or process, the sequence of calls to enable additional device contexts can include FillLogicalDeviceBlock and, depending upon a requirement that the driver posts in the initial enable sequence, includes or excludes FillPhysicalDeviceBlock.

Each of the Close Transaction functions undoes actions taken by a corresponding Open Transaction function. For example, theEnableDeviceContext subfunction allocates the DDC data area within the presentation driver and returns the hDDC handle. The DisableDeviceContext subfunction deallocates the DDC data area.

The FillLogicalDeviceBlock transaction occurs when a thread of a process opens the first instance of a DC for this presentation driver. During this transaction, a dispatch table will be created for later use by the graphics engine.

The FillPhysicalDeviceBlock transaction will occur only if the result flags from the FillLogicalDeviceBlock transaction indicate that it is necessary. See the description of Bit 2 under FillPhysicalDeviceBlock.

This subfunction is used by presentation drivers that support multiple types of physical devices. It will occur during the DevOpenDC call for every DC associated with a particular type of physical device. (This is where any memory allocation and initializations relating to a physical device should be done.) During the EnableDeviceContext transaction, the presentation driver will allocate and format the driver-specific data (DDC) associated with the DC being constructed. At CompleteOpenDC time, the DC is completely constructed and initialized. This transaction gives the presentation driver anopportunity to make final adjustments to the DC before the application gets access to it.

If either the FillLogicalDeviceBlock or FillPhysicalDeviceBlock transaction returns a failure return code, no other transactions are requested by the graphics engine.

If the EnableDeviceContext fails, the DisablePhysicalDeviceBlock transaction is sent to the presentation driver. If the CompleteOpenDC transaction fails, the BeginCloseDC, DisableDeviceContext, and DisablePhysicalDeviceBlock transactions are sent to the presentation driver .

If an application has opened a device context, but the application terminates before it closes the device context, the graphics engine still calls the disable routines BeginCloseDC, DisableDeviceContext, and DisablePhysicalDeviceBlock, as expected by the presentation driver when a device context is closed explicitly by an application.