I have read an article, from which I have recreated the paint function (called in case WM_PAINT:) in the following way:
case WM_PAINT: