Skip to main content

TdxCustomDockControl.OnRestoreDockPosition Event

Specify where the dock control is docked when its header is double-clicked.

Declaration

property OnRestoreDockPosition: TdxDockPositionEvent read; write;

Remarks

When a dock control is docked to a site, end-users can make it float by double-clicking its header. At this The control’s original position is stored in a TdxDockPosition structure. If the dock control’s caption is double-clicked again, the structure’s data is used to restore the control to its previous position. However, you may wish to control this yourself by handling the OnRestoreDockPosition event.

The Sender parameter of the OnRestoreDockPosition event identifies the control whose previous position is being restored. The APosition parameter provides information on the previous position of the dock control. You can modify settings of the structure represented by this parameter to change the position.

Note that settings provided by the APosition parameter can also be changed by handling the OnStoreDockPosition event. For instance, if a control is within a tab container, you can specify that it must be restored in the first position. However, the actual arrangement of dock controls may change since the event was raised. For instance, the tab container that owned this control may have been destroyed. Thus, you may need to make additional changes to the saved control’s position when handling the OnRestoreDockPosition event.

The code below is an example of an OnRestoreDockPosition event handler. The handler checks whether the dock control’s parent still exists. If it has been destroyed already, the control is docked to the right edge of the dock site. Such a situation can take place, for instance, if the dock control has been previously docked to a container site and all other controls have been undocked from the container.

procedure TForm1.dxDockPanel1RestoreDockPosition(Sender: TdxCustomDockControl; var APosition: TdxDockPosition);
begin
  if APosition.Parent = nil then
  begin
    APosition.Parent := dxDockSite1;
    APosition.DockType := dtRight;
  end;
end;
See Also