Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I only tested the first reproduction case (with D7, D2007, XE2), and am able to duplicate the problem with D7 and D2007 but not with XE2. </p> <p>The problem, as I see it, is that the label, having its font changed, requests its parent to re-align itself. This eventually leads to a <code>SetWindowPos</code> call on the form (in <code>TWinControl.AdjustSize</code>) with restored width/height even though the form is already maximized - which leads to the strange, <em>behaviorally maximized but not visually maximized</em>, form sitting on the screen.</p> <p><hr />I traced the code in D2007 and XE2 to be able to come up with what is different. The code in <code>TWinControl.AlignControls</code> is different between the two versions. What specifically matters is the last statement.</p> <p>D2007:</p> <pre><code>procedure TWinControl.AlignControls(AControl: TControl; var Rect: TRect); .. { Apply any constraints } if Showing then AdjustSize; end; </code></pre> <p>XE2:</p> <pre><code>procedure TWinControl.AlignControls(AControl: TControl; var Rect: TRect); .. // Apply any constraints if FAutoSize and Showing then DoAdjustSize; end; </code></pre> <p>I hope this, somehow, helps you devising/deciding what workaround to use. <hr /> <br /> The workaround I could suggest (although I haven't tested it throughly) is to force show the form maximized early:</p> <pre><code>procedure TForm1.FormCreate(Sender: TObject); var wplc: TWindowPlacement; begin if not AutoScroll and (WindowState = wsMaximized) then begin wplc.length := SizeOf(wplc); GetWindowPlacement(Handle, @wplc); wplc.rcNormalPosition.Right := wplc.rcNormalPosition.Left + Width; wplc.rcNormalPosition.Bottom := wplc.rcNormalPosition.Top + Height; wplc.showCmd := SW_MAXIMIZE; SetWindowPlacement(Handle, @wplc); end; end; </code></pre> <p>The above works because it forces to set the focus to the edit control (<code>OnEnter</code> event) before the VCL sets the visible flag for the form. In turn, the label's alignment request does not result with form size adjustment. Also, since, by the time VCL calls <code>ShowWindow</code> the form's window is already visible, it doesn't cause the form to be shown in a restored state at any stage.</p> <p>However, I don't know if it would help with different reproduction scenarios.</p> <hr /> <p>Finally, although I can see that the behavior is <em>corrected</em> in newer Delphi versions, I wouldn't consider this to be a bug in the VCL. In my opinion, user code should be responsible not to cause window adjustment while window showing state is changing. The course of action I'd take for the specific scenario would be to defer to modify label's font until the VCL is done displaying the form.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload