I have an application written in Delphi 6 and compiled on Windows XP. Usually I leave 8px free between controls and the edges of forms.
When this app runs on Vista o
Short version: change all form's to AutoScroll = False
The problem is the form's AutoScroll
property, and how it affects which form size is stored in the DFM.
If AutoScroll
is true (the default) the DFM will store Width
and Height
:
object Form1: TForm1
Left = 192
Top = 114
Width = 544
Height = 375
Caption = 'Form1'
...
If AutoScroll
is false (the preferred setting) the DFM will store ClientWidth
and ClientHeight
:
object frmSplash: TfrmSplash
Left = 192
Top = 114
ClientWidth = 536
ClientHeight = 348
Caption = 'Form1'
The problem with storing Height
is what happens when the user's caption bar is a different size than your development machine, e.g.
Windows 2000 had a 4 pixel border, with a 23 pixel caption bar. With the DFM storing a Height
of 375, this leaves 348px for form client area.
Run the same program on Windows XP, which has a taller (28 pixel) caption bar. With the DFM storing a Height
of 375 pixels, this leaves 343px for client area.
Your form "got 5 pixels shorter".
You need to force Delphi to store the ClientWidth
and ClientHeight
in the DFM by turning AutoScroll
off.
Now when you create your 348px tall form on Windows XP, it will continue to have 348 pixels in the client area - and be however extra tall is required to have a caption bar.
i go so far as to have an OutputDebugString
and a breakpoint trigger if my helper library code finds any form that mistakenly has AutoScroll
set to true.
Edit: Since i try to be a good developer, i make my form's respect the user's font preference. During the OnCreate
of all my forms i call a StandardizeForm(Self)
function that:
Scaled
AutoScroll
true (and sets it to false)ShowHint
is false (and turns it on)You can do something similar. Yes you'd have to add:
procedure TCustomerEditForm.FormCreat(Sender: TObject);
begin
StandardizeForm(Self); //Pay your taxes!
...
end;
But it's worth it for me.