我想在image1 和image2中插入一个Tcontrol类的控件,使其成image1->tcontrol->image2的z轴次序排列

解决方案 »

  1.   

    说说这样做的目的。
    TImage 不是窗口类。
      

  2.   

    生成的Tcontrol类的控件是用来控制处于他z轴次序下的控件。
    我看了一下TControl的vcl源码他好像是使用SetZOrderPosition
    用来重新设置次序
    FParent.FControls.Delete(I);
    FParent.FControls.Insert(Position, Self);
    可是无法访问其fControls的私有成员。TComponent提供
    DYNAMIC void __fastcall SetChildOrder(TComponent* Child, int Order);
    方法,似乎是改变z轴次序的方法,可是他没有GetChildOrder,我就不知到如何得到image1的当前的次序(order)了。望各位相助。
      

  3.   

    Use SetZOrder to move rearrange overlapping controls within a parent control or overlapping windows on the screen. If the TopMost parameter is True, the control becomes the top control; otherwise, it becomes the bottom control. Windowed controls always stack on top of non-windowed controls. Thus, if the Parent contains any non-windowed controls, calling SetZOrder with a TopMost value of False will still keep the windowed control above all the non-windowed controls.其中有说Windowed controls总是在non-windowed controls的上面。所以TImage是不能放在TButton的上面的。但是可以在TLabel的上面,因为它们同属non-windowed controls.
    如果把你的Image放到一个Panel中,把Panel的AutoSize设为True,并把Panel的BevelOuter设为bvNone,其它属性取默认值。然后通过设置Panel的Zorder可以Windowed controls进行前后置换。
      

  4.   

    我知道Windowed controls总是在non-windowed controls的上面,但是
    如果单看non-windowed controls也有次序,我并不奢望image在button上,但是
    我想,如果是tControl控件应该也可以吧,因为他可作为image的父类。谢谢 ahjoe(强哥) 提出的建议,可是我不能改,这一改程序改动就大了。