The WinFillRect function fills (paints) a rectangle with a specified color. For example, to fill an entire window with blue in response to a WM_PAINT message, you could use the following code fragment, which is taken from a window procedure:
HPS hps; RECTL rcl; case WM_PAINT: hps = WinBeginPaint(hwnd, (HPS) NULL, (PRECTL) NULL); WinQueryWindowRect(hwnd, &rcl); WinFillRect(hps, &rcl, CLR_BLUE); WinEndPaint(hps); return 0;
A more efficient way of painting a client window is to pass a rectangle to the WinBeginPaint function. The rectangle is set to the coordinates of the rectangle that encloses the update region of the window. Drawing in this rectangle updates the window, which can make drawing faster if only a small portion of the window needs to be painted. This method is shown in the following code fragment. Notice that WinFillRect uses the presentation space and a rectangle defined in window coordinates to guide the paint operation.
HPS hps; RECTL rcl; case WM_PAINT: hps = WinBeginPaint(hwnd, (HPS) NULL, &rcl); WinFillRect(hps, &rcl, CLR_BLUE); WinEndPaint(hps); return 0;
You could draw the entire window during the WM_PAINT message, but the graphics output would be clipped to the update region.
The default method of indicating that a particular portion of a window has been selected is using the WinInvertRect function to invert the rectangle's bits.