4.1.13 Physical Objects

Physical objects are device-dependent representations of the logical pens, brushes, and fonts that Windows applications use to perform output. GDI directs a printer driver to create physical objects whenever an application selects a logical object for subsequent drawing. The process of converting a logical object into a physical object is called realizing the object, and every printer driver provides a RealizeObject function to carry out this task.

GDI calls the RealizeObject function when an application calls the SelectObject function (GDI.45) to select a logical object for a device context. GDI calls the function twice: once to retrieve the size of the physical object, and a second time to realize the object. Although the printer driver realizes an object, GDI manages it, allocating memory for the object, passing the object to the driver to perform output, and deleting the object when it is no longer needed.

GDI realizes a physical object when it is selected to avoid the overhead of realizing the object each time it is used for drawing. The contents and organization of the structure defining a physical object are specific to the driver. Usually, the structure includes the logical object plus any other information that the driver needs.