Modify the WM_DESTROY Case

Before terminating the Output application, you should delete the drawing tools created for Output's window; this frees the memory that each drawing tool uses. To do this, use the DeleteObject function to delete the various pens and brushes in the WM_DESTROY case. Modify the WM_DESTROY case so that it looks like this:

case WM_DESTROY:

DeleteObject(hRedBrush);

DeleteObject(hGreenBrush);

DeleteObject(hBlueBrush);

DeleteObject(hDashPen);

DeleteObject(hDotPen);

PostQuitMessage(0);

break;

You must include one DeleteObject function call for each object to be deleted.