Skip to main content

TdxCustomDockControl.OnCanResize Event

Enables you to restrict control resizing to particular positions.

Declaration

property OnCanResize: TdxCanResizeEvent read; write;

Remarks

When a dock control is docked to an edge of a dock site or when it resides within a side container, you can resize it by dragging its border. Before a dock control is actually resized, the OnCanResize event fires. The Sender parameter identifies the control being resized. The NewWidth and NewHeight parameters indicate the width and height that the control will have if the resizing operation is successful. The Resize parameter specifies whether resizing to these dimensions is allowed. If it is set to False, the resize operation is rejected and the control snaps back to its original size.

You can identify whether the control is being resized horizontally or vertically by reading its DockType property value. If this property returns either dtLeft or dtRight, the control is being resized horizontally. If either dtTop or dtBottom is returned, the control is being resized vertically.

The following sample code handles the OnCanResize event to change the dock control’s horizontal resizing behavior. It allows control resizing only within the range of 100 and 200 pixels. Also, it allows only widths divisible by 20. (In other words, only the 100, 120, 140, 160, 180 and 200 pixels widths are allowed.)

procedure TForm1.dxDockPanel1CanResize(Sender: TObject; NewWidth, NewHeight: Integer; var Resize: Boolean);
begin
  with Sender as TdxCustomDockControl do
  begin
    if (DockType = dtLeft) or (DockType = dtRight) then
    begin
      if (NewWidth < 100) or (NewWidth > 200) then
        Resize := False;
      if NewWidth mod 20 <> 0 then
        Resize := False;
    end;
  end;
end;
See Also