While developing an application that performs scientific calculations and displays the results graphically, I noticed that TControl.DoSetBounds raises an exception if Width or Height are greater than 100.000, as can be seen from the following code.
procedure TControl.DoSetBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure BoundsOutOfBounds;
begin
DebugLn('TControl.DoSetBounds ',Name,':',ClassName,
' Old=',dbgs(Left,Top,Width,Height),
' New=',dbgs(aLeft,aTop,aWidth,aHeight),
'');
RaiseGDBException('TControl.DoSetBounds '+Name+':'+ClassName+' Invalid bounds');
end;
begin
if (AWidth>100000) or (AHeight>100000) then
BoundsOutOfBounds;
{$IFDEF CHECK_POSITION}
if CheckPosition(Self) then
DebugLn(['TControl.DoSetBounds ',DbgSName(Self),
' Old=',Left,',',Top,',',Width,'x',Height,
' New=',aLeft,',',aTop,',',aWidth,'x',aHeight]);
{$ENDIF}
FLeft := ALeft;
FTop := ATop;
FWidth := AWidth;
FHeight := AHeight;
if Parent <> nil then Parent.InvalidatePreferredSize;
end;
Regarding this, I have two questions:
- While the requirement that an object cannot exceed the above value is certainly reasonable, is there a specific reason behind this atypical limit?
- Is it possible, in future versions of LCL, to avoid hardcoding this value and instead make it a public constant (for example, in the interface section), thus allowing applications using LCL to implement check mechanisms that prevent this limit from being exceeded and thus throwing the exception during program execution?
Thanks in advance.