Private Device Contexts

Normally, applications share and retrieve device contexts right before use and release them right after use. This works best for applications that do not frequently require a DC for painting.

An application that requires a DC on an ongoing basis can create a window with its own private DC by specifying the CS_OWNDC class style in the class definition for the window. With this class style, the device context exists for the life of the window. The application still uses GetDC to retrieve a handle to the device context but doesn't need to call ReleaseDC after using the device context. Using a private device context with programs that alter the device context settings means changes—such as new text colors, pens, and brushes—remain ...

Get Microsoft Windows 2000 API SuperBible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.