delphi 程序适应屏幕分辨率,先在表单单元的Interface部分定义两个常量,


表示设计时的屏幕的宽度和高度(以像素为单位)。


在表单的Create事件中先判断 当前分辨率是否与设计分辨率相同,


如果不同,调用表单的SCALE过程重新能调整表单中控件的宽度和高度。


Const   Orignwidth=800;   Orignheight=600;


 


procedure TForm1.FormCreate(Sender:TObject);


begin  


  scaled:=true;  


  if (screen.width<>orignwidth) then  


  begin    


    height:=longint(height)*longint(screen.height)div orignheight; 


    width:=longint(width)*longint(screen.width)div orignwidth;    


    scaleby(screen.width,orignwidth);  


  end;


end;