Asked By Bello
21-May-08 09:12 AM

The CreateBitmap definition in MSDN says that :
calling the SelectObject() function. However, the bitmap can only be selected
into a device context if the bitmap and the DC have the same format".
The CreateCompatibleDC definition in MSDB say that :
display surface is exactly one monochrome pixel wide and one monochrome pixel
high".
If these two statements are correct, it would be impossible to select a
bitmap different than a monochrome bitmap into a memory DC, which clearly is
not the case, since that's the usual procedure to expand a memory DC, before
painting on it.
I've done some tests, selecting bitmaps obtained with CreateBitmap() and
with different color depths (bpp). The 1 and 32 bpp bitmaps are selected
normally by the function SelectObject(). For the other cases (4, 8, 16, 24)
the function fails.
Given the above contradictions, I have some conceptual questions :
. Which of the first two statements above is true ?
. Why does (4) occurs ?
. Given that a memory DC returned by CreateCompatibleDC(hDC) is different
from hDC, what is the meaning of the term Compatible in the function's name
? At least one would expect this funtion to return a memory DC with the same
color organization as hDC.
. A memory DC, does it really have a default bitmap, or is it just a
placeholder ?
Microsoft Visual C++ .NET 69586-335-0000007-18101