background
When the windows do the drawing, for beauty, often to the four corners of the window to make some pictures or rounded corners. For example QQ window:
Fillet of implementation summary
- In fact, sum up very simple, two-step process:
- Calculation of the window border cleavage domain
- Windows API by
SetWindowRgn
setting the clipping region of the window
- In fact, the principle is, set up after the cut domain boundary, the boundary pixel windows will be cut in the domain are removed.
Detailed steps
1. Calculate the window border cleavage domain
- MFC may be utilized in
CRgn
class - Use
CreateRectRgn
to create a cleavage domain boundary- It can be used
CreateRoundRectRgn
to create a rounded rectangle region CreateEllipticRgn
To create an elliptical cleavage domainCreatePolygonRgn
Creating polygon clipping region
- It can be used
- Used
CombineRgn
to modify the cleavage domain boundaries, common bit as follows:RGN_AND
RGN_OR
RGN_XOR
RGN_DIFF
RGN_COPY
2. Set the window border cleavage domain
- Using the
SetWindowRgn
API to set the window clipping region- Need to pass parameters: domain boundary shear handle
HRGN
- Need to pass parameters: whether to trigger a redraw
- Need to pass parameters: domain boundary shear handle
- The above two steps, can be simply understood as:
- Windows windows set to be "cut off" the area
- After the windows system domain redrawn every time, this part of the region will be "cut off", thus achieving a rounded shape of window or other rich