我是在800*600的小字体下开发的程序界面,但是在1024*768下大字体下用的时候整个的界面的布局就没有原来的那么协调了,请问我怎么控制在任何分辨率都能和我设计的时候一样。

解决方案 »

  1.   

    用代码控制Resize事件,在其中先获得屏幕的分辨率,然后再改变控件的大小与布局
      

  2.   

    设计界面时多用Tpanel控件和控件的Align属性,这样就不用担心分辨率的问题了。
      

  3.   

    呵呵,给你个代码,不是我写的,参考下
    const
      DefaultWidth = 800;
      DefaultHeight = 600;type
      TfrmJtBaseScale = class(TfrmJtBase)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;  TMyControl = class(TControl);
    implementation{$R *.dfm}procedure TfrmJtBaseScale.FormCreate(Sender: TObject);
    var
      i: integer;
      a: real;
    begin
      if Screen.Width <> DefaultWidth then
      begin
        height:=longint(height)*longint(screen.height) div DefaultHeight;
        width:=longint(width)*longint(screen.width) div DefaultWidth;
        scaleby(screen.width , DefaultWidth);
        for i := 0 to self.ControlCount -1 do
        begin
          a := screen.Height / DefaultHeight * TMyControl(self.Controls[i]).Font.Size;
          TMyControl(self.Controls[i]).Font.Size := trunc(a);
        end;
      end;
    end;随分辨率改变