我如何知道控件将停靠在哪里,以及如何阻止停靠?
我正在使用 Delphi 的“常规”对接(DockSite = True 和 UseDockManager = True)。现在有几个 DockSite 控件和几个可停靠窗体。然而,并非每个可停靠表单都应该放入每个停靠站点中。
表单知道它们应该停靠在哪种控件上;控件,OTOH,不知道接受或不接受什么形式。
现在我的问题是,有几个事件发生,您可以在其中取消拖放(或拖放)操作:DragOver、StartDock 等。但这些都发生在“接收”端,而不是发生在“接收”端。被放弃的控制;这就是我想要的地方 - 以便被停靠的窗体可以拒绝停靠到某个控件。
是否存在这样的事件,我是否忽略了某些事情,或者我是否必须以不同的方式解决这个问题?
I’m using Delphi’s 'regular' docking (with DockSite = True and UseDockManager = True). Now there’s several DockSite controls, and several dockable forms. However, not each dockable form is supposed to go in each dock site.
The forms know what kind of control they’re supposed to dock onto; the controls, OTOH, don’t know what form to accept or not.
My problem, now, is that there’s several events going off where you can cancel a drag/drop (or drag/dock) operation: DragOver, StartDock, etc. But those all occur on the 'receiving' side, never on the side of the control that’s being dropped; and that’s where I’d like to have it — so that the form being docked can refuse being docked to a certain control.
Is there such an event, am I overlooking something, or would I have to tackle this in a different way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我应该将其添加为答案,而不仅仅是评论。为您的自定义表单创建一个基本表单,并将您的逻辑放入其中。然后每个控件只需要知道如何与一个表单类交互即可。您创建的每个新对接表单都必须从该基本表单派生。这样做的好处是您不需要制作控件的自定义版本,因为一切都可以通过标准事件处理程序来处理。
I figured I should add this as an answer instead of just a comment. Create a base form for your custom forms and put your logic in that. Then each control would simply have to know how to interact with one form class. Each new docking form you make would have to descend from this base form. The beauty of this is that you will not need to make custom versions of your controls since everything can be handled through the standard event handlers.
OnStartDock
事件是为正在停靠的控件/窗体触发的,而不是为正在停靠的 DockSite 控件触发的。因此,您可以为可停靠表单分配一个 OnStartDock 事件处理程序,或者更好地重写虚拟的 DoStartDock() 方法。The
OnStartDock
event is fired for the control/form that is being docked, not for the DockSite control that is being docked onto. So you can assign anOnStartDock
event handler to your dockable forms, or better override the virtualDoStartDock()
method.