我想设置 image 和 panel 的显示顺序,可是panel一直在前面,查找发现setchildorder用来设置顺序,可是不管用,为什么?

解决方案 »

  1.   

    TImage继承自TGraphicControl,所以不能把TImage显示在TWinControl的前面(TPanel继承自TWinControl)。
      

  2.   

    image没有句柄,是non-windowed控件,而Panel是windowed控件,non-windowed控件总是在windowed控件后。设置了也没用。见delphi的帮助:The stacking order of windowed and non-windowed controls cannot be mingled. For example, if you put a memo, a windowed control, on a form, and then put a label, a non-windowed control, on top of it, the label disappears behind the memo. Windowed controls always stack on top of non-windowed controls. In this example, calling the SetZOrder method of the label or the memo has no effect, the label always remains behind the memo.如果要摆在panel前面,把image放在另一个panel上,然后设置这个panel的位置。