Click here to Skip to main content
15,896,402 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in the following code:
C++
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&memDC, 100, 100);
memDC.SelectObject(&bmp);

memDC gets a monochrome DC. why?
i expect CreateCompatibleDC creates a color DC like the screen!
if i change the code into:
C++
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap bmp;
CClientDC dc(NULL);
bmp.CreateCompatibleBitmap(&dc, 100, 100);
memDC.SelectObject(&bmp);

memDC gets a color DC!
how can u describe it?
thx
Posted

1 solution

Have a look at the description of CreateCompatibleBitmap[^]:

"Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory device context is used in CreateCompatibleBitmap, the bitmap that is created is a monochrome bitmap. To create a color bitmap, use the HDC that was used to create the memory device context, as shown in the following code:"
 
Share this answer
 
Comments
ilostmyid2 29-Feb-12 4:29am    
thank u :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900