【问题标题】:Delphi FMX - control paint order of controlsDelphi FMX - 控制控件的绘制顺序
【发布时间】:2013-12-09 09:25:48
【问题描述】:

我想控制窗体上每个控件的绘制顺序。

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

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

【问题讨论】:

  • 猜猜可以为此制作一个自定义 TControl 编辑器,可能可以基于此:en.delphipraxis.net/topic/… - 我会在此类编辑器中显示一个子名称列表,允许对它们进行重新排序。如果 IDE 提供这样的操作会很好

标签: delphi delphi-xe firemonkey


【解决方案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; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-05
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多