+ -
当前位置:首页 → 问答吧 → 如何知道TSplitter控件的左右各是什么控件

如何知道TSplitter控件的左右各是什么控件

时间:2011-09-28

来源:互联网

求助:
  TSplitter假设是靠左停靠的,那么我有没办法获取到我左边他停靠的是什么控件?  
  或者如何做成一个通用的方法可以保存TSplitter的配置,前提不需要知道他左边右边是什么控件?

作者: macjie   发布时间: 2011-09-28

自己做标记吧,比如用tag做

作者: bdmh   发布时间: 2011-09-28

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

作者: sz_haitao   发布时间: 2011-09-28

引用 1 楼 bdmh 的回复:

自己做标记吧,比如用tag做


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

作者: macjie   发布时间: 2011-09-28

引用 2 楼 sz_haitao 的回复:

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

这个我也知道呀,可是没找到,能否帮忙下,谢了~~~

作者: macjie   发布时间: 2011-09-28

Delphi(Pascal) code
看看这个代码能不能找到:
  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;

作者: sz_haitao   发布时间: 2011-09-28