Add the WM_PAINT Case

To be sure that the text string and selection rectangle are redrawn when necessary (for example, when another window has temporarily covered the client area), add the following case to the window function:

case WM_PAINT:

{

PAINTSTRUCT ps;

hDC = BeginPaint (hWnd, &ps);

if( OrgX != PrevX || OrgY != PrevY ) {

MoveTo(hDC, OrgX, OrgY);

LineTo(hDC, OrgX, PrevY);

LineTo(hDC, PrevX, PrevY);

LineTo(hDC, PrevX, OrgY);

LineTo(hDC, OrgX, OrgY);

}

TextOut(hDC, 1, 1, str, strlen (str));

EndPaint(hWnd, &ps);

}

break;