开发者

How do I know where a control will be docked, and how do I prevent the docking?

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 d开发者_如何转开发rag/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?


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.


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 an OnStartDock event handler to your dockable forms, or better override the virtual DoStartDock() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜