Create a new application, add the docking site, add 2 or more panels to the docking site, let's say Panel1, Panel2 and Panel3
Create the OnCloseQuery event for Panel1. Assign the same method (Panel1CloseQuery) to the OnCloseQuery event of all panels.
so you have
Panel1.OnCloseQuery = Panel1CloseQuery.
Panel2.OnCloseQuery = Panel1CloseQuery.
Panel3.OnCloseQuery = Panel1CloseQuery.
Make this the code of the method:
procedure TForm1.Panel1CloseQuery(Sender: TObject; var CanClose: Boolean);
if sender is TLMDDockPanel then
CanClose := false; // << this is just so you can repeat the test as much as you want
Run the application.
Undock panel1 and leave it floating on the desktop. Undock panel2 and panel3 and dock both into Panel1.
Hit the 'x' close button on any panel.
The Sender will always be Panel1, for any of the 'x' buttons you press.
I expected that hitting the 'x' of Panel2 would call the event with the sender = Panel2, and the same for Panel3.
Is that something that can be fixed?
This is way worse than I first thought.
When you attempt to close a docked panel, the OnCloseQuery event happens to ALL panels in that site, even for the not visible ones!
And unless all the handlers set CanClose to true, it won't close. And when it closes, it closes ALL the panels!
This makes absolutely no sense to me, can you please review how this works?