문제

The Rect function is declared in two units:

System.Classes.Rect
System.Types.Rect

Why this ambiguity? Is one of these functions deprecated? Which one should be preferred?

도움이 되었습니까?

해결책

From the documentation, System.Types.Rect takes integer values for the four corners of the rectangle; System.Classes.Rect on the other hand also provides an overload that takes two TPoints - one for top-left, one for bottom right. Both return a TRect so it's really a matter of choice which you use.

The latter is more flexible (offering two overloads) so it's probably best to make sure you include Classes after Types in your uses clause (if using both) to not hide the more versatile method provided by Classes.

다른 팁

If you're to call Rect in a tight loop (which doesn't do I/O or similar), consider calling types.Rect, which is what classes.Rect really does; it calls types.Rect (but then you may need to inline your own Rect...). Otherwise it doesn't matter, I wouldn't bother including 'types' in 'uses' just to save one level of indirection.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top