你可以通过设置autoscroll属性为true来解决这个问题。但是这将引起更多的问题!
运行期间,DELPHI得到系统的屏幕分辨率并把它保存到Screen对象的 PixelsPerInch 属性中,接着DELPHI使用 PixelsPerInch 的值来确定当前分辨率下的窗口大小。
注意: 把FORM的Scaled属性设置为TRUE, TrueType fonts, use Windows small fonts when you develop, and set the AutoScroll property of your form(s) to FALSE.
另一种解决方案:
要使你写的应用程序在任何分辨率下的效果一样,可以如下编程:
implementation
const
ScreenWidth: LongInt = 800; {在分辨率为 800x600 的模式下编程.}
ScreenHeight: LongInt = 600;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
scaled := true;
if (screen.width <> ScreenWidth) then
begin
//以下指form1的height & width
height:=longint(height)*longint(screen.height) DIV ScreenHeight;
width := longint(width) * longint(screen.width) DIV ScreenWidth;
scaleBy(screen.width, ScreenWidth);
end;
end;
接着检查字体设置是否合适. 在修改font设置前,必须确保构件有此属性. 方法如下:
USES typinfo; {Add this to your USES statement.}
var
i: integer;
begin
for i := componentCount - 1 downto 0 do
with components do
begin
if GetPropInfo(ClassInfo, 'font') <> nil then
font.size := (NewFormWidth DIV OldFormWidth) * font.size;
end;
end;
* 设计程序时可设定窗口的scaled属性. 设为false的优点是运行时和设计时一致。 缺点是大小在不同分辨率下不一致。
1、 设置 Form确的 Scaled 属性为 True.
2、 设置 AutoScroll 为 False.
3、 设置字体为可缩放的字体:TrueType font, 比如:Arial. MS
San Serif , but remember that it is still a bitmapped font. Only Arial will give you a font within a pixel of the desired height. 注意: 如果该字体未在目标计算机安装,则WINDOWS将选择相近的字体,此时字体设置失效。
4、不要把窗口的position属性设置为poDesigned,因为分辨率不同将导致窗口的位置不同。
5、不要把构件堆积在一块,至少应有 4 pixels 的距离。
6、对于单行标签,如果它的align属性设置为 alLeft or alRight ,请设置
AutoSize 为 True. 否则设置为false.
7、 确保标签构件有足够的空间容纳变化了的字体 - a blank space that is 25% of the length of the current string display length is a little too much, but safe.
(You'll need at least 30% expansion space for string labels if you
plan to translate your app into other languages) If AutoSize is
False, make sure you actually set the label width appropriately. If AutoSize is True, make sure there is enough room for the label to grow on its own.
8、 In multi-line, word-wrapped labels, leave at least one line of
blank space at the bottom. You'll need this to catch the overflow
when the text wraps differently when the font width changes with
scaling. Don't assume that because you're using large fonts, you
don't have to allow for text overflow - somebody else's large fonts may be larger than yours!
9、 在不同分辨率下用DELPHI的IDE打开工程时,必须修改PixelsPerInch属性
10、 Speaking of component drift, don't rescale a form multiple times,at design time or a runtime. Each rescaling introduces roundoff errors which accumulate very quickly since coordinates are strictly integral. As fractional amounts are truncated off control's origins and sizes with each successive rescaling, the controls will appear to creep northwest and get smaller. If you want to allow your users to rescale the form any number of times, start with a freshly loaded/created form before each scaling, so that scaling errors do not accumulate.
11、 Don't change the PixelsPerInch property of the form, period.
12、 In general, it is not necessary to design forms at any particular resolution, but it is crucial that you review their appearance at 640x480 with small fonts and large, and at a high-resolution with small fonts and large before releasing your app. This should be part of your regular system compatibility testing checklist.
13、 Pay close attention to any components that are essentially
single-line TMemos - things like TDBLookupCombo. The Windows
multi-line edit control always shows only whole lines of text - if
the control is too short for its font, a TMemo will show nothing at all (a TEdit will show clipped text). For such components, it's
better to make them a few pixels too large than to be one pixel too
small and show not text at all.
14、 Keep in mind that all scaling is proportional to the difference in the font height between runtime and design time, NOT the pixel
resolution or screen size. Remember also that the origins of your
controls will be changed when the form is scaled - you can't very
well make components bigger without also moving them over a bit.