Problems Using Delphi 5 Forms with Vista
I have developed code with Delphi 5 for a long time.
However, with Vista 64, the main forms (the user interface)
do not display correctly .. and, in fact,
are unusable
..
when the Delphi defaults are used.
It is my opinion that this is an intentional move by Microsoft
to make all existing software non-functional.
(There is no way that this is simply some accident.
If it was, it would have been fixed in service pack 2.)
I have written several totally trivial programs to demonstrate the problem.
They are located in
the zip file.
Basically, the forms contain 3 buttons
- One in the upper left hand corner
- One near the lower right hand corner .. but not touching the border
- One near the lower right hand corner that is pinned (anchored) to that corner
The form size is fairly small (250x150) so that screen captures can be displayed at full size.
One button saves a jpeg of the form image ..
just to simplify creating this help page.
Basics
| Examples
| Comment
| References
Basics
In order to get the forms to work in Vista, 3 properties must be changed.
- TForm.Scaled must be false
- This keeps scroll bars from being displayed in Vista.
This has no effect in Windows XP.
- TForm.Autoscroll must be false
- If this is not done, then objects anchored to the right and bottom edges
of the form will be rendered in the wrong place in Windows XP
when Form.Scaled is false.
- TForm.Font.Name must be something other than MS Sans Serif
- In Vista, when the font is MS Sans Serif, it is automatically replaced
with a larger font and some text will no longer fit inside the buttons.
If you really want AutoScroll to be true
(I do), set it in FormCreate
.. at that point, the damage is already done (I mean - prevented).
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.AutoScroll := true;
end;
|
Examples
This is just a basic form with 3 buttons - Form_Test.exe.
Form2_Test.exe is identical to Form_Test.exe except for 2 edit fields
and some code to load the fields and set the form size.
XP | Vista | Comment
|
---|
Default form .. before Button 3 was anchored
Default.exe
TForm.Scaled = true
TForm.Autoscroll = true
XP - All 3 buttons are visible
Vista - Different font size, button size, and scrollbars
|
Button 3 is anchored to the lower right hand corner
Button3_Anchored.exe
TForm.Scaled = true
TForm.Autoscroll = true
XP - All 3 buttons are visible
Vista - The vertical scrollbar is gone, enlarging the form will not
make Button 3 visible
|
Scaled_Off.exe
TForm.Scaled = false
TForm.Autoscroll = true
XP - Button 3 is in the wrong place - VCL error.
Vista - Buttons are smaller and the scrollbars are gone. Still has a larger font size.
|
Scaled_Autoscroll_Off.exe
TForm.Scaled = false
TForm.Autoscroll = false
XP - All 3 buttons look good
Vista - All the buttons are the correct size and in the correct place.
Text in button 2 is too large.
|
Form with all the changes
New_Font.exe
TForm.Scaled = false
TForm.Autoscroll = false
form1.Font.Name = 'microsoft sans serif';
Both systems are showing similar content
Success :)
|
Autoscroll_Off.exe
TForm.Scaled = true
TForm.Autoscroll = false
XP - All 3 buttons look good
Vista - All the buttons are displayed and expanded to display the text.
| | | | | | | | | | | | |
Comment
Most of the help I have found online indicates how to make your
Windows XP applications look like they were designed for Vista.
What I want is for my application to look the same on every Windows platform.
What kind of an idiot spends time designing something and then wants
someone else to change how it looks. It is like having some museum
changing the color of the flowers in a painting ..
or changing a seascape to a mountain valley.
Sorry .. I consider that to be vandalism and a despicable copyright violation.
In fact, this is probably a design error in Vista. The compatibility options
should have worked.
(Of course, I tried all the Vista compatibility settings .. and many different combinations.
I never saw any difference. None at all.)
However, the fact that this problem has been there for a number of years
indicates that it might be intentional.
On the other hand, it is pretty apparent that the Delphi 5 VCL contains a design error ..
the scaling should have worked.
Another source of trouble is
TForm.Constraints -
a set of 4 properties that can be used
to control the minimum and maximum width and height of your forms.
(Vista - the OS that keeps on giving.)
(Thanks to a reader - include an email address if you want a response.)
References
-
Make the text on your screen larger or smaller
- How to use the Windows 7 dpi setting to change the application size.
(I simply assume that Vista is similar since I see similar dialog boxes.)
- Near the bottom, this explains how to enable the Windows XP style DPI scaling.
On my system, the check box was checked .. but also greyed out.
-
MS Sans Serif font is bigger
- "In windows 7, the [MS Sans Serif] font is bigger, and it results missing characters in cells and missing rows on the program tables." August 8, 2010
-
The only response describes a registry hack - however, it is not acceptable
for me to tell people to hack the registry to run my code.
This is also where I got the previous link.
-
Microsoft Sans Serif
- This indicates that MS Sans Serif is a bit mapped font
and that Microsoft Sans Serif is "metrically compatible"
(whatever that may mean)
-
Put MS Sans Serif back in to your menus
- "While you may select any other font in the display properties for pull down menus, if you select MS Sans Serif MS Office and other recent MS applications will automatically replace your selection with Tahoma."
-
This helped me discover that Microsoft treats MS Sans Serif differently
from all other fonts. Specifically, in buttons, the application always displayed
the same font size regardless of what I did. When I selected Arial,
my font size changes had an effect. This reference indicated that the font name
was causing the problem.
From the provided examples,
the difference between Tahoma and MS Sans Serif
is the size of the dots in the ellipses. In fact, that is the only obvious difference.
(There are numerous other differences, but at 8 points they are not so obvious.)
-
Fonts for the Web
- This provides examples and descriptions of many common fonts.
However, it incorrectly indicates that Tahoma is a monospaced font.
-
How to deal with form size issues from Delphi 6 and WinXP to Delphi 2007 and Vista/Win7
- This had the real answer
change all form's to AutoScroll = False
Author:
Robert Clemenzi