13.3.5 Adding a WM_PAINT Case

A WM_PAINT case is necessary to draw the current client-area text on the screen when the window has been minimized, resized, or overlaid. To create this case, add the following statements to the window procedure:

case WM_PAINT:

    hdc = BeginPaint(hwnd, &ps);
    if (hText != NULL) {
        if ((lpszText = GlobalLock (hText)) == NULL) {
            OutOfMemory();
        }

        else {
            GetClientRect(hwnd, &rectClient);
            DrawText(hdc, lpszText, -1, &rectClient,
                DT_EXTERNALLEADING | DT_NOPREFIX | DT_WORDBREAK);
            GlobalUnlock (hText);
        }
    }

    EndPaint(hwnd, &ps);
    break;