What does TRect mean with exchanged (left, top) and (right, bottom) points?

I read 3-way Delphi sources and stick to the line where Rect is initialized using other Rect coordinates, but swapped, for example:

r, rsrc: TRect; ... r := Rect(rsrc.right + 1, rsrc.bottom + 1, rsrc.left, rsrc.top); 

rsrc filled with the correct screen coordinates, so (left, top) is always smaller (right, bottom).

What does it mean? I cannot find any mention of the possible purpose of this in the Delphi documentation.

+4
source share
2 answers

This does not mean anything, as SomeVarName := 7 does not mean anything on it. Look further into the code and see what r should be used for; Also see how rsrc was obtained.

It just might be that the coordinates for rsrc were obtained using some math, and it was determined that the resulting rectangle was up side, so the code rotates the rectangle up and down.

+6
source

Strictly speaking, a TRect is just a collection of four integers. The meaning of these numbers depends entirely on the context. Most often they indicate a rectangle.

That is, it makes no sense to expect that the Delphi documentation will say anything about the current problem! This is similar to how a car makes a U-turn on a small road and asks: β€œWhy doesn't the car manual explain why someone will make a U-turn on this road?”

+11
source

Source: https://habr.com/ru/post/1396058/


All Articles