Polygon is alsoThe GDI object also complies with the rules of other GDI objects, but it is usually not selected into the DC. In MFC, polygon is represented by CRgn. A polygon is used to represent a region different from a rectangle and has similar operations with a rectangle. For example, it checks whether a point is internal and performs operations. In addition, a minimum rectangle containing the polygon is obtained. The following describes the member functions of the polygon class:
CreateRectRgn creates a polygon from the rectangle.
CreateEllipticRgn: Creates a polygon from an elliptic
CreatePolygonRgn: Create a polygon with multiple points
Whether a point in PtInRegion is inside
CombineRgn
Whether two polygon of EqualRgn are equal
In this section, the significance of polygon is to improve the efficiency of plotting in the window. The reason for causing the window re-painting is that a certain area is invalid, and the invalid area is represented by a polygon. Assume that the window size is500*400 when another window above moves from (0, 0, 10) to (20, 20, 30, 30), the area (0, 0, 10, 10) becomes invalid, you only need to re-paint this part of the area rather than all areas, so that your program execution efficiency will increase.
By callingThe API function int GetClipRgn (HDC hdc, HRGN hrgn) can be used to obtain the invalid region. However, generally, you only need to obtain the smallest rectangle containing the region, therefore, you can use int CDC: GetClipBox (LPRECT lpRect) to complete this function.