Delphi FMX - 控制控件的油漆顺序

时间:2013-11-24 19:20:04

标签: delphi delphi-xe firemonkey

我想控制表单中每个控件的绘制顺序。

我知道我可以在设计动作中控制它,它实际上改变了表单中控件的创建顺序。

但是有没有办法在运行时改变它?

1 个答案:

答案 0 :(得分:1)

您可能会发现它取决于父对象子项列表中项目的顺序。管理对象子项有各种函数:

public
    //Returns the component we are a child of, which may not be the immediate parent
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    procedure AddObject(const AObject: TFmxObject);
    procedure InsertObject(Index: Integer; const AObject: TFmxObject);
    procedure RemoveObject(const AObject: TFmxObject); overload;
    procedure RemoveObject(Index: Integer); overload;
    function ContainsObject(AObject: TFmxObject): Boolean; virtual;
    procedure Exchange(const AObject1, AObject2: TFmxObject); virtual;
    procedure DeleteChildren;
    function IsChild(AObject: TFmxObject): Boolean; virtual;
    //Front and back (first and last) of Children list
    procedure BringToFront; virtual;
    procedure SendToBack; virtual;
    procedure AddObjectsToList(const AList: TFmxObjectList);
    procedure Sort(Compare: TFmxObjectSortCompare); virtual;
    property ChildrenCount: Integer read GetChildrenCount;
    property Children: TFmxChildrenList read FChildrenList;
    property Parent: TFmxObject read FParent write SetParent;
    //a.k.a. Parent.Children.IndexOf(Self)
    property Index: Integer read GetIndex write SetIndex;