Chapter 8 GDI Orientation and Transformations Visual C++ and MFC Fundamentals
- Change its ID to IDB_LADY
- Add a message handler of the WM_PAINT message for the CBitmap1View class
and implement it as follows:
void CBitmap1View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBitmap BmpLady;
CDC MemDCLady;
// Load the bitmap from the resource
BmpLady.LoadBitmap(IDB_LADY);
// Create a memory device compatible with the above CPaintDC variable
MemDCLady.CreateCompatibleDC(&dc);
// Select the new bitmap
CBitmap *BmpPrevious = MemDCLady.SelectObject(&BmpLady);
// Copy the bits from the memory DC into the current dc
dc.BitBlt(20, 10, 436, 364, &MemDCLady, 0, 0, SRCCOPY);
// Restore the old bitmap
dc.SelectObject(BmpPrevious);
// Do not call CView::OnPaint() for painting messages
}
- Test the application
- Return to MSVC