>I have a Delphi program written on a computer with small fonts installed.
>When this is run on a computer with identical properties except for the fact
>that large fonts are being used all the controls on the forms seem to have
>expanded in size leading to scrollbars appearing on all the forms. The forms
>themselves seem to remain at the correct size.
>
>How can I resolve this so that it will work correctly on a system with
>either font size?
A1:
I’m wondering if you have maximum size form constrains ?
This could be preventing Delphi from resizing the form as
well as all the controls. Add code like what follows to
detect and address the problem.
on create event
[code lang=”delphi”]var
Ratio: double;
begin
Ratio := Self.PixelsPerInch / 96;
Self.Contraints.MaxWidth := Self.Contraints.MaxWidth * Ratio;
Self.Contraints.MaxHeight := Self.Contraints.MaxHeight * Ratio;
Self.Width := Self.Width * Ratio;
Self.Height := Self.Height * Ratio;
end;
[/code]
A2:
a simple solution see “large fonts” on
http://www.inner-smile.com/delphifaq.htm , it says :
Design on large fonts, use only truetype fonts, set the forms Scaled
property to false. That works pretty well on smallfont systems. You
just have to make sure that your form does not become larger than the
users screen size. This can be handled by a simple check in the forms
OnCreate procedure, call
SystemparametersInfo( SPI_GETWORKAREA, 0, @aRect, 0 );
Check if your forms width or height exceed the dimensions of aRect, if
so you set your forms Boundsrect := aRect; and the forms AutoScroll
property to true. It then gets scrollbars but that is better than
having parts of the form not accessible by the user.
A3:
You can design in small fonts. Just set Scaled to false, and use a
TrueType font (rather than MS Sans Serif). Also, don’t anchor things to
the bottom or right–Delphi has a bug with that if Scaled is false.
A4:
People who switch to ‘large fonts’ do this because they find the small
fonts hard to read. So everything should grow with large fonts. This
means your ‘fixed-size’ (not scrollable) forms must expand in size.
Set the form’s Scaled property to True, and the AutoScroll property to
False.
[tags]Delphi, Forms[/tags]
0 Kommentare zu “Small Fonts / Large Fonts…”