Fix to Mantis 28654 in svn 50942 prevents Width/Height being set to ClientWidth/ClientHeight in TControl.Loaded
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
Conditions:
LFM has settings for ClientWidth/ClientHeight and any Constraint but no setting for Width or Height.
What happens:
When the Constraint value is loaded, TControl.DoConstraintsChange is called, Width and Height are set to default values (no constraints are actually applied because Effective values are negated during loading) and the cfWidthLoaded flag is set.
Now when TControl.Loaded is entered both cfClientWidthLoaded and cfWidthLoaded are set and Width will not be loaded with ClientWidth (or Height).
Steps to reproduce:
See attached project
Additional information:
Here is a patch
Index: lcl/include/control.inc
===================================================================
--- lcl/include/control.inc (revision 52186)
+++ lcl/include/control.inc (working copy)
@@ -1372,8 +1372,10 @@
------------------------------------------------------------------------------}
procedure TControl.DoConstraintsChange(Sender : TObject);
begin
- Width:=Constraints.MinMaxWidth(Width);
- Height:=Constraints.MinMaxHeight(Height);
+ if cfWidthLoaded in FControlFlags then
+ Width:=Constraints.MinMaxWidth(Width);
+ if cfHeightLoaded in FControlFlags then
+ Height:=Constraints.MinMaxHeight(Height);
AdjustSize;
end;
The fix checks for cfWidthLoaded and cfHeightLoaded before calling the constraints. This fixes the documented problem. I tested it against 28654 and it does not break that fix.
Could also check for 'csLoading in ComponentState' as TSizeContraints.EffectiveMinWidth or Height exit out during this condition and no constraints are actually applied.