The invalidate function marks the drawing area as invalidated. This flag is used when the window is redrawn, if the area is invalidated it will redraw the area, if not it will just leave the screen area as it is. invalidate invalidates the whole client area of a given object, invalidaterect invalidates a specific region of the client area. The update function does the actual redraw.
The reason for such a mechanism, and not just drawing immediately when you know something has to be changed is that you can prevent multiple redraws, say for example you received three keydown messages in one go, which scroll some text area. If you redrew the text area for each of the key presses you would have to draw the text area three times and the application would become unresponsive. By instead processing all the key events, updating the data structure attached to the text area and invalidating the text area before you redraw the textarea, you only redraw the textarea once.