How to achieve a rounded window windows

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:
  1. Calculation of the window border cleavage domain
  2. Windows API by SetWindowRgnsetting 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 CRgnclass
  • Use CreateRectRgnto create a cleavage domain boundary
    • It can be used CreateRoundRectRgnto create a rounded rectangle region
    • CreateEllipticRgnTo create an elliptical cleavage domain
    • CreatePolygonRgnCreating polygon clipping region
  • Used CombineRgnto 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 SetWindowRgnAPI to set the window clipping region
    • Need to pass parameters: domain boundary shear handleHRGN
    • Need to pass parameters: whether to trigger a redraw
  • The above two steps, can be simply understood as:
    1. Windows windows set to be "cut off" the area
    2. 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

Reference connection

Guess you like

Origin www.cnblogs.com/HelloGreen/p/11531092.html