The Delphi Bug List

Entry No.
436
VCL - General - Controls - TControl
Anchored Controls are not resized if Form's initial WindowState set to wsMaximized
1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 4.03 5.0 5.01 6.0 6.01 6.02 Kylix 1.0
N/AN/AN/AN/AN/AExistsExistsExistsExistsExistsExistsExistsExistsExistsN/A
Description
Reported by Steve Maughan and Greg Chapman; checked by Reinier Sterkenburg
To see the erroneous behavior, create a form, drop a control on it and set the Control's Anchor property to include all four anchor types (akLeft..akBottom). Then set the Form's WindowState to wsMaximized. When you run the app and show the Form, it maximizes, but the control dropped on it stays the same size.

I believe this problem occurs because most of the special resizing code is turned off during form loading. Note in particular TWinControl.UpdateLastResize which appears to be crucial in saving information for the next time AlignControls is called. If I am correct, this problem should not be limited to setting WindowState:= wsMaximized; it will also show up for any property changed during form loading which causes the form to have a different size than it had in the Delphi form-designer. I'm not sure how big a problem that may be.

Matthew Collins notes:
Also affects MDI child forms that are created with poDefault as the Forms initial position. The form takes the default size and position, but the controls on it are not resized.

Solution / workaround
The work around for wsMaximized is fairly simple. Just leave the form's designed WindowState as wsNormal, and then set it to wsMaximized in FormCreate.
Latest update of this entry: 2002-04-03

Post a comment on this bug


Index page
Delphi Bug List home page
The Delphi Bug Lists are presently maintained by Jordan Russell, who has taken over this task from Reinier Sterkenburg since August 2000.
All feedback is appreciated. See also the feedback section of the Delphi Bug List home page.