[英]Keep a control on top in the delphi designer
I created a simple design-time component that helps to select and bring to front other components on the same form. 我创建了一个简单的设计时组件,该组件可以帮助选择和展示同一表单上的其他组件。 (It is more convenient than IDE object tree view when designing full screen forms in a single monitor environment).
(在单个监视器环境中设计全屏窗体时,它比IDE对象树视图更方便)。 But in Delphi XE2, I cannot reliably ensure and detect that the helper component itself is on the top.
但是,在Delphi XE2中,我无法可靠地确保和检测到辅助组件本身位于顶部。 When I select it, the IDE draws 8 blue balls as a marker around it, and it seems to me that those markers are part of the actual top level window.
当我选择它时,IDE会在其周围绘制8个蓝色的球作为标记,在我看来,这些标记是实际顶层窗口的一部分。
So, how could I check if a component is selected in the IDE designer? 那么,如何检查IDE设计器中是否选择了组件?
So, how could I check if a component is selected in the IDE designer?
那么,如何检查IDE设计器中是否选择了组件?
Create a design-time editor for your component (make sure you implement it in a designtime-only package, not a runtime package), and register it with RegisterComponentEditor()
. 为您的组件创建一个设计时编辑器(确保您在仅设计时的包中而不是在运行时包中实现它),然后向
RegisterComponentEditor()
注册它。 TComponentEditor
has a Designer
property to access the Form Designer's IDesigner
interface, which has a GetSelections()
method: TComponentEditor
具有一个Designer
属性,用于访问表单设计器的IDesigner
接口,该接口具有GetSelections()
方法:
procedure GetSelections(const List: IDesignerSelections);
IDesignerSelections
has Count
and Items[]
properties, where Items[]
returns a TPersistent
object. IDesignerSelections
具有Count
和Items[]
属性,其中Items[]
返回一个TPersistent
对象。 So you can loop through the list looking for your desired component object(s) (all components derive from TPersistent
). 因此,您可以在列表中循环查找所需的组件对象(所有组件均来自
TPersistent
)。
IDesigner
also has SelectComponent()
and SetSelections()
methods, so you can have the Form Designer select other components as needed: IDesigner
还具有SelectComponent()
和SetSelections()
方法,因此您可以让Form Designer根据需要选择其他组件:
procedure SelectComponent(Instance: TPersistent); overload;
procedure SelectComponent(const ADesignObject: IDesignObject); overload;
procedure SetSelections(const List: IDesignerSelections);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.