请问窗体大小变化时,里面的控件该如何计算才能随窗体放大缩小

解决方案 »

  1.   

    可以用一些Panel来对窗口布局,也可以自己处理消息来调整控件的位置
      

  2.   

    比如说edit,选择它的属性Anchors下面的四个属性akLeft、akTop、akRight、akBottom值都设置为True则可随窗口缩放而缩放。
      

  3.   

    1.Panel布局比较简单;
    2.自己修改;
      

  4.   

    唔,都不成设置Anchors的属性为后,将窗体最大化后里面的按钮都大得了不得,不符合申美观;如加个panel,panel是可以随窗体变大缩小,panel里面的控件却屹然不变,如也设置其Anchors属性,则好像也不雅观,不知各位有当拉动窗口边框改变其大小时,里面的控件有按其比例缩放的代码否?
      

  5.   

    控件不多的话可以在窗口的onResize事件里面加一些控制控件比例的代码。
    我以前这么试过,现在也是将控件放在Panel里面,挺好的啊。
      

  6.   

    有一個控件叫resizers有這個功能.拉這個控件放在窗體中然后在窗口的onResize事件里面寫resizers1.resize(self or sender都可以).
      

  7.   

    好象是要编代码的:
        onformCreate事件 
    self.width:=screen.width; 
    self.height:=screen.height这是使窗口最大话!
      

  8.   

    把anchors的四个属性都设置成true 那么的他的大小就是随窗口的大小 变化而变化了
      

  9.   

    给楼主一段代码,可以自动计算窗口大小的变化量,希望会有用吧。
    procedure TFStateReopen.FormCreate(Sender: TObject);
    begin
      InitClientHeight:= ClientHeight;    //要先在窗体类中声名这些Integer变量
      InitClientWidth:= ClientWidth;
      CurClientHeight:= ClientHeight;
      CurClientWidth:= ClientWidth;
    end;procedure TFStateReopen.FormResize(Sender: TObject);
    begin
      inherited;
      //计算可视组件的坐标变化
      HeightInc:= ClientHeight - CurClientHeight;
      if HeightInc > 0 then
      begin
        CurClientHeight:= ClientHeight;
      end;
      if (HeightInc < 0) and (ClientHeight > InitClientHeight) then
      begin
        CurClientHeight:= ClientHeight;
      end;
      if (HeightInc <0) and (ClientHeight <= InitClientHeight) then
      begin
        HeightInc:= InitClientHeight - CurClientHeight;
        CurClientHeight:= InitClientHeight;
      end;
      WidthInc:= ClientWidth - CurClientWidth;
      if WidthInc > 0 then
      begin
        CurClientWidth:= ClientWidth;
      end;
      if (WidthInc < 0) and (ClientWidth > InitClientWidth) then
      begin
        CurClientWidth:= ClientWidth;
      end;
      if (WidthInc <0) and (ClientWidth <= InitClientWidth) then
      begin
        WidthInc:= InitClientWidth - CurClientWidth;
        CurClientWidth:= InitClientWidth;
      end;
      //调整组件位置
      GroupBox1.Width:= GroupBox1.Width + WidthInc;   //楼主要自己定这些调整大小和位置的语句
      GroupBox2.Width:= GroupBox2.Width + WidthInc;
      GroupBox2.Height:= GroupBox2.Height + HeightInc;
      GroupBox3.Width:= GroupBox3.Width + WidthInc;
      GroupBox3.Top:= GroupBox3.Top + HeightInc;
      PanelButton.Width:= PanelButton.Width + WidthInc;
      PanelButton.Top:= PanelButton.Top + HeightInc;
    end;
      

  10.   

    1,利用panel控件
    2,利用Anchors的四个属性akLeft、akTop、akRight、akBottom
    3,取得窗口的大小,计算