From d898e73213c51c75c4c1865ff573234f65e1cdd0 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Tue, 3 Mar 2026 17:36:53 -0600 Subject: [PATCH] Move form sizing to after Show so font metrics are fully realized Sizing the form in the constructor via HandleNeeded was unreliable -- RecalcCellSize runs again during Show with different font metrics, shrinking FAnsi while the form keeps its stale size. Move the ClientWidth/ClientHeight assignment into Run after Show, when handles are fully created and RecalcCellSize has settled. Restore constructor Width/Height defaults in TKPAnsi for reasonable pre-handle dimensions. Remove CP437 box-drawing diagnostic from the terminal. Co-Authored-By: Claude Opus 4.6 --- delphi/KPANSI.PAS | 2 ++ delphi/TESTMAIN.PAS | 18 ++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/delphi/KPANSI.PAS b/delphi/KPANSI.PAS index 528b0d1..ee051c6 100644 --- a/delphi/KPANSI.PAS +++ b/delphi/KPANSI.PAS @@ -318,6 +318,8 @@ var Line: PTermLine; begin inherited Create(AOwner); + Width := 660; + Height := 450; Color := clBlack; TabStop := True; FCols := 80; diff --git a/delphi/TESTMAIN.PAS b/delphi/TESTMAIN.PAS index fabcf84..b87b838 100644 --- a/delphi/TESTMAIN.PAS +++ b/delphi/TESTMAIN.PAS @@ -151,18 +151,6 @@ begin FAnsi.Top := 38; FAnsi.OnKeyData := AnsiKeyData; - { Size form to fit terminal + toolbar } - ClientWidth := FAnsi.Width; - ClientHeight := FAnsi.Top + FAnsi.Height; - - { Font diagnostic: write known CP437 box-drawing characters. } - { If the OEM font is working, you should see: } - { Line 1: single-line box top +---+ } - { Line 2: shade + full block ░▒▓█ } - { Line 3: single-line box bottom +---+ } - { If you see accented letters, the font is ANSI_CHARSET instead of } - { OEM_CHARSET. } - FAnsi.Write(#$DA#$C4#$C4#$C4#$BF' '#$B0#$B1#$B2#$DB' '#$C0#$C4#$C4#$C4#$D9#13#10); end; @@ -176,6 +164,12 @@ var HasData: Boolean; begin Show; + + { Size form to fit terminal + toolbar. Show triggers handle creation } + { and RecalcCellSize, so FAnsi.Width/Height reflect measured font. } + ClientWidth := FAnsi.Width; + ClientHeight := FAnsi.Top + FAnsi.Height; + FDone := False; while not FDone do begin