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 or Win 7 this gap is smaller or not present at all. I think this might be because these versions of Windows have thicker form borders.
Now I am moving the app to Delphi 2007. In the form designer the forms have lost the bottom and right gaps.
How should I deal with this? I have hundreds of forms and don’t want to go changing them all. Also, most of our users run the app on Win XP so I don’t want to make it look bad in XP.
Short version: change all form’s to
AutoScroll = FalseThe problem is the form’s
AutoScrollproperty, and how it affects which form size is stored in the DFM.If
AutoScrollis true (the default) the DFM will storeWidthandHeight:If
AutoScrollis false (the preferred setting) the DFM will storeClientWidthandClientHeight:The problem with storing
Heightis 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
Heightof 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
Heightof 375 pixels, this leaves 343px for client area.Your form “got 5 pixels shorter”.
You need to force Delphi to store the
ClientWidthandClientHeightin the DFM by turningAutoScrolloff.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
OutputDebugStringand a breakpoint trigger if my helper library code finds any form that mistakenly hasAutoScrollset to true.Edit: Since i try to be a good developer, i make my form’s respect the user’s font preference. During the
OnCreateof all my forms i call aStandardizeForm(Self)function that:ScaledAutoScrolltrue (and sets it to false)ShowHintis false (and turns it on)You can do something similar. Yes you’d have to add:
But it’s worth it for me.