A window and its associated presentation space have three regions that control where drawing takes place in the window. These regions ensure that the application does not draw outside the boundaries of the window or intrude into the space of an overlapping window.
┌───────────────┬─────────────────────────────────────────────┐ │Region │Description │ ├───────────────┼─────────────────────────────────────────────┤ │Update Region │This region represents the area of the window│ │ │that needs to be redrawn. This region changes│ │ │when overlapping windows change their z-order│ │ │or when an application explicitly adds an │ │ │area to the update region to force a window │ │ │to be painted. │ ├───────────────┼─────────────────────────────────────────────┤ │Clip Region │This region and the visible region determine │ │ │where drawing takes place. Applications can │ │ │change the clip region to limit drawing to a │ │ │particular portion of a window. Typically, a │ │ │presentation space is created with a clip │ │ │region equal to NULL, which makes this region│ │ │equivalent to the update region. │ ├───────────────┼─────────────────────────────────────────────┤ │Visible Region │This region and the clip region determine │ │ │where drawing takes place. The system changes│ │ │the visible region to represent the portion │ │ │of a window that is visible. Typically, the │ │ │visible region is used to mask out │ │ │overlapping windows. When an application │ │ │calls the WinBeginPaint function in response │ │ │to a WM_PAINT message, the system sets the │ │ │visible region to the intersection of the │ │ │visible region and the update region to │ │ │produce a new visible region. Applications │ │ │cannot change the visible region directly. │ └───────────────┴─────────────────────────────────────────────┘Whenever drawing occurs in a window's presentation space, the output is clipped to the intersection of the visible region and clip region.
The clip region includes the overlapped part of the back window, but the visible region excludes that portion of the back window. The system maintains the visible region to protect other windows on the screen; the application maintains the clip region to specify the portion of the window in which it draws. Together, these two regions provide safe and controllable clipping.
To further control drawing, both the system and the application manipulate the update region. For example, if a window's position is switched from back to front, positions front to back, several changes occur in the regions of both windows. The system adds the lower-right corner of the new front window to that window's visible region. The system also adds that corner area to the window's update region.