Device Context Confusion



Hello,
In the course of debugging some memory leaks, I noticed that my graphics
routines were rather inconsistent. Sometimes I ReleaseDC( ), then
DeleteObject( ) on the drawing resources; sometimes vice versa. The examples
I see throughout forums and MSDN proper also show inconsistent ordering.
So, suppose I create:
1 Pen, 1 Brush, 1 Font, 1 Compatible Bitmap within a function. At the end
of this function, what is the proper cleanup?...

Delete the drawing resources first, then ReleaseDC()? Vice versa?
Sometimes I've seen DeleteDC() rather than ReleaseDC(). I want to structure
the cleanup properly so that I can eliminate this situation as a cause of
resource leaks.
Thanks to all,
- eep!
.


Loading