Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxCustomDockControl.OnCloseQuery Event

In This Article

Enables you to override the control’s behavior when it is being closed.

#Declaration

Delphi
property OnCloseQuery: TdxDockControlCloseQueryEvent read; write;

#Remarks

End-users can close a dock control by clicking the close button within the control’s caption. You can also close the control using code by calling its Close method. In both cases, the OnCloseQuery event is raised before the control is actually closed. Handle this event if you need to restrict control closing depending on conditions or if you require custom functionality. If you only need to perform actions when closing a control, handle the OnClose event instead.

Use the event’s CanClose parameter to specify whether closing is allowed. If you need to prevent the control closing depending on conditions, simply set this parameter to False when these are met. The control being closed is identified by the Sender parameter.

The following code shows how to handle the OnCloseQuery event to implement custom closing behavior. It cancels the default behavior and, instead, docks the dock control to the left edge of a dock site and enables the control’s auto hide feature.

Delphi
procedure TForm1.dxDockPanel1CloseQuery(Sender: TdxCustomDockControl; var CanClose: Boolean);
begin
  CanClose := False;
  Sender.DockTo(dxDockSite1, dtLeft, -1);
  Sender.AutoHide := True;
end;
See Also