本帖最后由 macjie 于 2011-09-28 16:18:59 编辑

解决方案 »

  1.   

    应该可以由程序自动找到:
    同一个parent 而且 left小于spliter.left的 控件
      

  2.   


    能否不用tag,都写成一个通用的方法了要是还要设置这个就没什么用了,那就和直接改变他停靠的位置的控件的大小一个意思了
      

  3.   

    看看这个代码能不能找到:
      procedure doSplitter(sp:TSplitter);
      var
        i:Integer;
        p:TControl;
      begin
        for i:=0 to sp.Owner.ComponentCount-1 do
          if (sp.Owner.Components[i] is TControl) then
          Begin
            p:=sp.Owner.Components[i] as TControl;
            if p is TSplitter then
              Continue;
            if not (sp.Parent=p.parent) then
              Continue;
            if not sp.Visible then
              Continue;
            if (sp.Align=alleft) and (p.Align=alleft) and (p.Left<=sp.Left)
            or (sp.Align=alright) and (p.Align=alright) and (p.Left>=sp.Left) then
            Begin
              self.rwWidth(p)
              Continue;
            End;
            if (sp.Align=altop) and (p.Align=altop) and (p.Top<=sp.Top)
            or (sp.Align=albottom) and (p.Align=albottom) and (p.Top>=sp.Top) then
            begin
              self.rwHeight(p)
              Continue;
            End;
          End;
      end;
      

  4.   

    谢谢楼上的代码
    用控件遍历的办法确实是一个办法  可是总有很多未知的问题
    比如说你的TSplitter位置你怎么知道是横的还是竖的
    而且代码量实在有点不适合
      

  5.   

    TSplitter位置是横的还是竖的,很容易:看sp.Align
    关键是要找它的最近的一个控件我上面的代码只是找到一个就算了
      

  6.   

    1、TSplitter一般与TPanel搭配使用。用TSplitter分隔TPanel
    2、在TPanel上放置其它控件