Skip to main content

Resize Zones

  • 5 minutes to read

Resize Zones Functionality


Resize zones, as well as dock zones, are descendants of the TdxZone class. They are dock control areas where resizing operations can be started. These areas reside at control edges. One of their dimensions is specified by the length of the corresponding edge. Another is specified by the zone width which is set as the constructor parameter. Then, this width can be obtained using the Width property of the zone object. The calculated bounding rectangle of the zone is returned by the Rectangle property.

The image below shows an example of a resize zone.

When the mouse pointer is over a dock control, the control’s ResizeZones list is scanned. If a resize zone residing under the mouse pointer is found, the cursor’s appearance changes to indicate that resizing can be initiated. If the zone’s Direction property returns zdVertical, the mouse cursor is changed to a vertical splitter. If zdHorizontal is returned, it is changed to a horizontal splitter.

If resizing starts, the CanResize method of the zone is called in response to mouse movements. This method determines whether the control’s edge can be moved to a position where the mouse pointer resides. If resizing can be performed, the zone paints a resizing bar indicating the potential position of the control’s edge. The bounding rectangle of the bar is returned by the GetResizingSelection method of the zone object. The current mouse pointer location is passed to this method as the parameter.

When the dragging operation is complete, the resize zone changes the size of the owner control. This owner control is returned by the Owner property of the zone object. Note that this property’s return value doesn’t necessarily match the control whose ResizeZones list contains this zone. The following section describes when this can happen.

How Resize Zones Lists are Populated


Each time the layout of dock controls changes, a list of resize zones is repopulated. The reason is that resize zones can be supplied to a control by its parent and parents may change as a result of docking operations.

If a dock control is not within a tab container or a side container, its own resize zones are added to the ResizeZones list. This means that the owner of these zones will be the control itself. In this case, a single resize zone is added if the control is docked to an edge of a dock site or layout site. The type of added zone is determined by the docking type of the control. For instance, if a dock control is docked to the left edge, a right resize zone is added. Thus, the control can be resized by dragging its right edge. An example is shown in the image below. Note that if the control is floating or occupies the entire area of the parent site, no resize zones are added to the list.

If within a tab container or a side container, the parent provides dock zones for the control. The owner of zones is the parent control in this case. The logic behind determining zone type is the same as described in the previous paragraph. The only addition is that vertical side containers provide bottom zones for their children (except the last one). Horizontal side containers provide right zones.

Suppose a tab container docked to the left edge of a dock site. When the mouse pointer is in the position displayed in the image below, it is actually above the tab container’s child panel. Thus, the panel’s zones will be used to implement resizing. However, when dragging the panel’s edge, its parent tab container must be resized. That is the reason for requesting resize zone from the parent control. The image shows how resize zones are formed in this case.

Consider a more complicated layout of dock controls.

All resize zones displayed in the image are owned by vertical side container. The process of populating the zones list can be described with the following points:

  • The vertical side container is docked to the left edge of a dock site. Thus, a right resize zone is added to its zones list (blue).

  • The tab container is within a side container. Thus, it requests resize zones from its parent. The side container provides two zones. The right zone (red) is provided to allow side container resizing by dragging the tab container’s edge. The bottom zone (green) is provided to allow resizing of side container’s children.

  • The bottom panel is the child of the vertical side container. Thus, it also requests resize zones from its parent. The supplied right zone (orange) enables resizing the vertical side container by dragging the panel’s edge.

  • The Output panel is within the tab container. Thus, it requests resize zones from its parent. The parent, it turn, requests zones from the owning side container. As a result, the right zone is added (yellow). This zone allows you to resize the vertical side container by dragging the panel’s right-most edge.

Populating Resize Zone Lists Manually


Each time the list of a dock control resize zones has been repopulated, the control raises an OnUpdateResizeZones event. You can handle this event to change the list of zones as needed. You can also provide a common logic of modifying resize zone lists for all dock controls. For this purpose, handle the OnUpdateResizeZones event of the docking manager.

The sample code below handles the OnUpdateResizeZones event of the docking manager. It removes all resize zones whose Direction property returns zdHorizontal. As a result, end-users will be unable to resize dock controls vertically.

procedure TForm1.dxDockingManager1UpdateResizeZones(Sender: TdxCustomDockControl; AZones: TList);
var I: Integer;
begin
  I := 0;
  while I < AZones.Count do
  begin
    if TdxZone(AZones.Items[I]).Direction = zdHorizontal then
      AZones.Delete(I)
    else
      Inc(I);
  end;
end;
See Also