关于FORM的大小?(30分)

  • 主题发起人 主题发起人 hjn
  • 开始时间 开始时间
H

hjn

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位大虾,如何做到FORM(及FORM中的控件)的大小会随屏幕分辨率的改变而自动改变?
 
我看应该是窗口中的字体会自动变化吧?
这个似乎Form有一个属性,忘记了,试试吧。
 
如果是要在小字体和大字体下自动改变,设置TForm.Scaled := true;
如果在800x600和1024x768下自动改变,自己写代码啦。(也有控件,但同自己
写代码没有什么区别)
 
设置TForm.Scaled := true
 
You can
solve this problem by letting Delphi automatically add scroll bars at run-time.
However, using Delphi's automatic scaling produces more professional results. At
run-time, Delphi asks the system for the screen resolution and stores it in the
PixelsPerInch property of your application's Screen object. Next, it uses the
PixelsPerInch value to resize the form for the current resolution. Here are some
things to remember, to make this technique work effectively: set the Scaled
property of your form(s) to TRUE, use only TrueType fonts, use Windows small
fonts when you develop, and set the AutoScroll property of your form(s) to
FALSE.
 
// 注意: Form1.AutoScroll := False;
// 字体最好用Arial;

const DesignWidth = 800; // 设计时: 800*600
procedure TForm1.FormCreate(Sender: TObject);
var
iAmountScaled: Integer;
begin
iAmountScaled := Round(Screen.Width * 100 / DesignWidth);
ScalBy(iAmountScaled, 100);
end;
 
读取屏幕的大小(screenwidth,screenheight),将form的大小与这两个参数相关就行了。
 
多人接受答案了。
 
后退
顶部