Modify the WM_DESTROY Case

You need to delete the bitmaps, patterns, brushes, and memory device context you have created before terminating the application. You delete bitmaps, patterns, and brushes by using the DeleteObject function. You delete the memory device context by using the DeleteDC function. Modify the WM_DESTROY case so that it looks like this:

case WM_DESTROY: /* message: destroy window */

SelectObject(hMemoryDC, hOldBitmap);

DeleteDC(hMemoryDC);

DeleteObject(hBrush);

DeleteObject(hPattern1);

DeleteObject(hPattern2);

DeleteObject(hPattern3);

DeleteObject(hPattern4);

DeleteObject(hBitmap1);

DeleteObject(hBitmap2);

DeleteObject(hBitmap3);

DeleteObject(hMenuBitmap1);

DeleteObject(hMenuBitmap2);

DeleteObject(hMenuBitmap3);

PostQuitMessage(0);

break;