I'm wondering , if I want to create different bitmaps,
I use the CreateCompatibleBitmap
function again and again, to associate it to the same memory CDC.
is it the same meaning that I CreateBitmap
and SelectObject
again and again??
I ask this question because I want to do something to the newly created bitmap by another CDC.
Without seeing the specific code it's hard to know the exact problem but CreateCompatibleBitmap is commonly used in double-buffering situations to avoid flickering. Rather than drawing directly to the Device Context (DC) you first draw to an off-screen, or memory, DC which is basically drawing to a bitmap. The bitmap is then copied directly to the screen DC using BitBlt, so it appears like all the drawing happens at the same time.
The usual steps are this (and will probably happen on every WM_PAINT):
CreateCompatibleBitmap
.BitBlt
the memory DC's bitmap onto the screen DC.More information available here: Guide to Win32 Memory DC (Code Project)