如何让程序窗体在运行时根据显示器的大小及像素来自动调整,使之美观?

解决方案 »

  1.   

    procedure FSetFormDisplayStart(Frm: TForm);
    var
      ScreenWidth, ScreenHeight : integer;
      FrmWidth, FrmHeight : integer;
    begin
      ScreenWidth := Screen.Width;
      ScreenHeight := Screen.Height;
      FrmWidth := Round(ScreenWidth / WidthScale);
      FrmHeight := Round(ScreenHeight / HeightScale);
      with Frm do
      begin
        Width := FrmWidth;
        Height := FrmHeight;
      end;
      FSetFormCenter(Frm);
    end;
    //WidthScale = 1.5;   //弹出窗体宽度和屏幕的宽比例
    //HeightScale = 1.8;   //高比例
      

  2.   

    如果只是调整一个Form上的控件,可以再OnResize事件中做调整,