The Delphi Bug List

Entry No.
470
VCL - General - Forms
A Form's WindowState property is not reported correctly in the FormResize event when maximizing/minimizing/restoring. The WindowState property gets updated AFTER the FormResize event.
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
AbsentAbsentAbsentAbsentAbsentExistsExistsExistsExistsUnknownUnknownUnknownUnknownUnknownN/A
Description
Reported by David Willis
To reproduce, check the value of the WindowState property in the FormReize event when maximizing and restoring. The value is incorrect. Delphi 1.02 and Delphi 3 give correct values. The attached code sample updates a label on a form with the currect value. Try maximizing and restoring.

To fix this bug, you need to edit the FORMS.PAS file. I haven't attempted a workaround that doesn't involve editing the VCL code, although I'm sure it would be possible by trapping the WM_SIZE message.

You need to adjust the TCustomForm.WMSize procedure so that the "inherited" line comes AFTER the case statement that sets the WindowState property. i.e.:

procedure TCustomForm.WMSize(var Message: TWMSize);
begin
  {inherited;}  // remove this line

  if not (csDesigning in ComponentState) then
    case Message.SizeType of
      SIZENORMAL: FWindowState := wsNormal;
      SIZEICONIC: FWindowState := wsMinimized;
      SIZEFULLSCREEN: FWindowState := wsMaximized;
    end;
  inherited;    // move line to here.
  RequestAlign;
  ......
I am using US English Delphi 4.0 Professional updated with the 12 August 1998 patch.
User-contributed comments
Thad Suits
29 Dec 2003  09:46 PM GMT
This bug still exists in Delphi 6.0. Unfortunately, the suggested work-around given for version 4 is obsolete under version 6. I would appreciate learning about an updated work-around.
Latest update of this entry: 1999-02-24

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.