如何让自己开发的程序在任何状(100分)

在800*600的显示状态下开发的应用程序,但转到了640*480或者大字体下,许多显示就
变的不太正常,目前有改变分辨率,或调正字体,让它与开发状太保持一致,但总觉的费力,有更好的办法吗?
 
这个问题已经有好几个人提出,不过没见到理想的结果,界面如何自动适应各种分辨率
很想知道这问题.
 
1、form.scaled 为false
2、通过指针去修改只读属性screen.pixelperinch
 
1.固定用户的分辨率;
2.用最小分辨率开发。
好象没有不麻烦的方法。
 
在一定的分辨率下设计界面,为了适应不同的分辨率,添加一段专门的代码:
const
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;

{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
scaled := true;
if (screen.width <> ScreenWidth) then
begin
height := longint(height) * longint(screen.height) div ScreenHeight;
width := longint(width) * longint(screen.width) div ScreenWidth;
scaleBy(screen.width, ScreenWidth);
end;
end;
然后检查窗口中的字体是否尺寸合适,可通过下面的代码实现:
type
TFooClass = class(TControl); { needed to get at protected }
{ font property }
var
i: integer;
begin
for i := ControlCount - 1 downto 0 do{迭代检查子窗口的字体}
TFooClass(Controls).Font.Size :=
(NewFormWidth div OldFormWidth) *TFooClass(Controls).Font.Size;
end;

 
多人接受答案了。
 
这么麻烦干什么?岂不是每个窗口都要加?只要将这些代码加在
project source里就可以了

96为设计时的form.pixelperinch值,可以保证其他人看的
时候和你看到的一样


var
p:^integer;

begin
Application.Initialize;
p:=@screen.PixelsPerInch;
p^:=round(p^/96*p^);
 
顶部