Introduction
There are some problems with maintaining resources for drawing, such as pens,
brushes, etc. When you select an object into a DC, that object becomes undeletable.
You might exit the context in which it was allocated, and its destructor is called,
and DeleteObject is ultimately called on it, but, surprise!, it hasn't
really gone away. Because it was selected into a DC, there is a flag saying it
is inactive use, and therefore your DeleteObject can't work. I don't know
the actual details of how this works internally, but I know the external manifestation.
The pen, brush, etc. simply stays in the "GDI heap".
If you are working on one of those horrid 16-bit windows-kludge-on-top-of-MS-DOS
systems like Windows 3.1, Windows 3.11, Win98, Win98, or WinME, (and if you
think that Win9x/ME is a 32-bit OS, you have (a) not read the API documentation
carefully (b) believed Microsoft's consumer-level documentation and thought it
was technical documentation) there is a very limited system-wide pool out
of which all pens and brushes are allocated, and eventually not even your desktop
can allocate the resources it needs to draw. On a real, 32-bit operating system
such as NT/2000/XP, the GDI heap is much larger, and is per-process, so eventually
your program won't be able to draw, but the rest of the system will work
fine, since you are only allowed to shoot yourself in the foot.