我在800*600分辨率下设计一个小程序,整体界面还可以,可是在1024*768下却变了样,请各位高手帮助解决这个问题,不甚感激。

解决方案 »

  1.   

    先在表单单元的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)divorignheight;
        width:=longint(width)*longint(screen.width)divorignwidth;
        scaleby(screen.width,orignwidth);
      end;
    end;