Getwindowrect is used to obtain the rect coordinates of the window in the screen coordinate system (including the customer and non-customer areas). In this way, the size of the window and the position relative to the upper left corner (0, 0) of the screen are obtained.
Getclientrect obtains the rect coordinates of the window client (excluding non-customer regions) in the client coordinate system. The size of the window is obtained, but the location of the screen is not obtained, this matrix is located in the client coordinate system (relative to the upper left corner of the window customer area.
The top left of the rect structure returned by getclientrect is zero, and the bottom right is the width and height of the customer area;
Screentoclient converts the rect coordinates in the screen coordinate system to the rect coordinates in the client coordinate system.
We first getwindowrect A rect for the same window, and then use screentoclient to convert it to the customer coordinate system.
Then, getclientrect gets a rect and converts it to the screen Coordinate System Using clienttoscreen.
Obviously, the matrix obtained by getwindowrect is not smaller than that obtained by getclientrect. Because the former includes non-customer areas and then the customer areas.
After screentoclient is obtained for the matrix obtained by getwindowrect, the size of the matrix is not reduced. Left and top are the coordinates in the upper left corner of the window, which are relative to the upper left corner of the window customer area.
After obtaining the clienttoscreen matrix obtained by getclientrect, the size of the matrix does not increase. The new matrix is the rect of the window client area in the screen coordinate system.
II,
Getwindowrect obtains the rect of the entire window, including the perimeter of the title bar and the screen coordinates.
Getclientrect obtains the customer zone. After a single document is created, the program runs. The white area in the window is the customer area and the customer coordinate.
Screentoclient is used to convert the screen coordinates into customer coordinates.
For example, if your screen is 1000*1000
You created a 100*100 window in 200*200
The rect you obtained using getwindowrect should be top = 100, Left = 100, Right = 300, Bottom = 300.
If the title bar of this window is 10 high, the rect obtained with getclientrect should be top = 0, Left = 0, Right = 200, Bottom = 190.
Now you have clicked on this window. If the screen is X = 200, y = 200, then after you use screentoclient to convert the screen, X will change
X = 100, y = 100