What does SelectObject (dc, hBMP) do?

I understand that I understand what will happen if I select an “object” in the “device contect” and if this object is a brush, font, pen: therefore, the symbols of these objects are used to draw on the device context.

However, I do not understand what happens after I select a bitmap image in the context of the device, and especially why it is necessary.

I have a program that someone is doing

HDC dc = ::GetDC(hWnd); ffBitmap = ::CreateCompatibleBitmap(dc, windowWidth, windowHeight); ffMemoryDc = ::CreateCompatibleDC(dc); hOldBitmap = (HBITMAP) ::SelectObject(ffMemoryDc, ffBitmap); 

and then calls ffMemoryDc, and then * BitBlt * s ffMemoyDc in the actual window device context.

 BitBlt ( dc, 0, 0, windowWidth, windowHeight, ffMemoryDc, 0, 0, SRCCOPY ); 

The ffBitmap variable is not specified anywhere in the entire program, but if I did not select SelectObject (ffBitmap), nothing is drawn, so this is .

I would be grateful if someone could shed light on what is happening here.

+7
source share
1 answer

How it works. The bitmap that you select in DC is the bitmap that is "drawn." MSDN Quote:

Before an application can use the memory device context for drawing operations, it must select a bitmap of the correct width and height in the device context.

+2
source

All Articles