本人用delphi开发程序是在1024×768分辨率的机器上,但现在要在800*600上使用,有些比较大的窗体就显示不全了,要拖来拖去,请高手讲下如何才能自动的适应啊?谢谢!

解决方案 »

  1.   


    inplementation
    const
      ScreenWidth: LongInt = 1024; {I designed my form in 1024×768 mode.}
      ScreenHeight: LongInt = 768;{$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;
      

  2.   

    同意楼上的,但是我觉的还要考虑Form里面的控件,Form小了有可能见不到某些控件
      

  3.   

    Form1.Scaled:=true;
    Form1.ScaleBy(768,1024);
      

  4.   

    WindowState := wsMaximized;
    還有調整控件的Align和Anchors屬性可以滿足這方面的需要.
      

  5.   

    从全局的对象Screen中可以取得很多有用的信息,如屏幕分辨率、可用字体列表、可用输入法列表等等,
    可以在窗体未显示之前通过Screen对象中获取的信息设置窗体大小,但是如果你在1024*768下设计的窗体大于800*600时,想在800*600的分辨率下获得良好的视图,比较麻烦,一般来说,由于800*600的分辨率显示器还很普遍,我们公司的软件界面,限制不能超过780*540,除非确定客户绝对不会在800*600分辨率下使用软件。