Creating and delete DeivceContext and bitmaps
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
hfFontDefault = CreateFont(lfHeight, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, _T("Times New Roman"));
bmTest= (HBITMAP)LoadBitmap(hInstance, _T("MyBitmap"));
image_dc = CreateCompatibleDC(hdc);
old_hbitmap = (HBITMAP)SelectObject(image_dc, bmTest);
BitBlt(hdc ,10 , 10, 1000, 1000, image_dc, 0, 0, SRCCOPY);
In the code above used the function CreateCompatibleDC to create a device context called image_dc for double buffering. I select hfFontDefault and bmTest bitmap into it. At the end of the WM_PAINT message, I select the old_hbitmap back into the image_dc.
Question 1: I have attached a diagram. Is the diagram an accurate representation of the device context in the code?
Question 2: I think itís safe to skip the last message to select the old_hbitmap back into image_dc before I DeleteDC(image_dc). However I would assume itís always a good idea to put it back. Is that true?
Question 3: the bmTest needs to be deleted, and I did so at the WM_DESTORY message. Right?