我的窗口设置是800X600 分辨率下,刚刚好。 
现在我想在各种分辨率下都能,自动拉伸。 
就像windows 背景图片那样的拉伸。
同时所有控件的大小,位置都按比例拉伸。
最好是有什么控件可以实现。

解决方案 »

  1.   

    什么控件也不需要。只需要把窗体上所有可见控件的Anchors的中的四个属性全部设置为False即可。
      

  2.   

     for i:=0 to self.ControlCount-1 do 
      begin 
        Controls[i].Width:=Controls[i].Width * 800 div screen.width; 
        Controls[i].Height:=Controls[i].Height * 600 div screen.Height; 
      end;
      

  3.   

    unit untFixForm;interfaceuses
    Classes, SysUtils, Controls, Forms;type
    TFontedControl = class(TControl)
    public
        property Font;
    end;TFontMapping = record
        SWidth : Integer;
        SHeight: Integer;
        FName: string;
        FSize: Integer;
    end;procedure FixForm(AForm: TForm);
    procedure SetFontMapping;var
    FontMapping : array of TFontMapping;implementationprocedure SetFontMapping;
    begin
    SetLength(FontMapping, 3);// 800 x 600
    FontMapping[0].SWidth := 800;
    FontMapping[0].SHeight := 600;
    FontMapping[0].FName := '宋体';
    FontMapping[0].FSize := 7;// 1024 x 768
    FontMapping[1].SWidth := 1024;
    FontMapping[1].SHeight := 768;
    FontMapping[1].FName := '宋体';
    FontMapping[1].FSize := 9;// 1280 x 1024
    FontMapping[2].SWidth := 1280;
    FontMapping[2].SHeight := 1024;
    FontMapping[2].FName := '宋体';
    FontMapping[2].FSize := 11;end; procedure FixForm(AForm: TForm);
    var
    i, j                 : integer;
    t                 : TControl;
    begin
    with AForm do
    begin
        for i := 0 to ComponentCount - 1 do
        begin
          try
            t := TControl(Components[i]);
            t.left := Trunc(t.left * (Screen.width / 1024));
            t.top := Trunc(t.Top * (Screen.Height / 768));
            t.Width := Trunc(t.Width * (Screen.Width / 1024));
            t.Height := Trunc(t.Height * (Screen.Height / 768));
          except
          end; { try }
        end; { for i }    for i:= 0 to Length(FontMapping) - 1 do
        begin
          if (Screen.Width = FontMapping[i].SWidth) and (Screen.Height = FontMapping[i].SHeight) then
          begin
            for j := 0 to ComponentCount - 1 do
            begin
              try
                TFontedControl(Components[j]).Font.Name := FontMapping[i].FName;
                TFontedControl(Components[j]).FONT.Size := FontMapping[i].FSize;
              except
              end; { try }
            end; { for j }
          end; { if }
        end; { for i }
    end; { with }
    end;initialization
    SetFontMapping;end.调用的话,
    procedure TForm1.FormShow(Sender: TObject);
    begin
    if MessageBox(Handle,'要使用屏幕自适应吗?','提示',MB_YESNO or MB_ICONINFORMATION) = idno then Exit;
    untFixForm.FixForm(Self);
    end;
    就行了