我的程序是在800*600的分辨率下做的,怎么样能使它在1024*768分辨率下运行时,自动调整窗体及其中的组件的位置和大小?
我用了scaleby,但不理想,字体的大小没有跟着变。
请问各位有什么高招?

解决方案 »

  1.   

    用Tpanel控件去调节,主要是align属性.
      

  2.   

    用Google去查查关于分辨率的自动调整在编程中是如何实现的,很多的
      

  3.   

    設置所有控件的 anchors 為 true!
      

  4.   

    不同分辨率下的屏幕控制:procedure TForm1.FormCreate(Sender: TObject);
    const
      ScreenWidth: LongInt = 800; {在800*600下开发的界面.}
      ScreenHeight: LongInt = 600;
    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;假設你在1024*780的分辨率下的form,第一步:
    inplementation
    const
      ScreenWidth: LongInt = 1024; {I designed my form in 800x600 mode.}
      ScreenHeight: LongInt = 780;{$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[i]).Font.Size :=
            (NewFormWidth div OldFormWidth) *
            TFooClass(Controls[i]).Font.Size;
    end;