Graphic Objects

All newly created DCs start with a default brush, palette, font, pen, and region. You can examine a default object's attributes by calling the GetCurrentObject and GetObject functions. The GetCurrentObject function returns a handle identifying the current pen, brush, palette, bitmap, or font, and the GetObject function initializes a structure containing that object's attributes.

To replace a default object, call one of the following object-specific creation functions

Graphic object Creation functions
Bitmap CreateBitmap, CreateCompatibleBitmap, CreateDIBSection
Brush CreateDIBPatternBrushPt, CreatePatternBrush, CreateSolidBrush
Palette CreatePalette
Font CreateFontIndirect
Pen CreatePen, CreatePenIndirect

Each of these functions returns a handle identifying the new object. After you retrieve a handle, you can call the SelectObject function to select the new object into the DC. However, you should save the handle to the default object. When you finish using the new object, use SelectObject to restore the default object, and delete the new object with the DeleteObject function.

Note Failure to delete objects that are no longer in use can cause serious performance problems.