Skip to main content

Docking Frame Custom Painting Sample

  • 2 minutes to read

You have the following options to paint a docking frame that is displayed during docking operations:

  • Fill this frame with the clHighlight system color. To do this, set the doFillDockingSelection flag in the Options property of a docking controller or manager).

  • Custom paint the docking frame by handling the docking manager’s OnCustomDrawDockingSelection event.

  • Custom paint the docking frame for an individual dock control by handling only the control’s OnCustomDrawDockingSelection event.

Refer to the Docking Frame and Resizing Bar Custom Painting topic, for basic information about these events.

The following sample code handles the OnCustomDrawDockingSelection event of the docking manager. If the potential state of the dock control is floating, the docking frame is painted by default. Otherwise, the potential position of the dock control is filled with an inverse solid brush.

procedure TForm1.dxDockingManager1CustomDrawDockingSelection(Sender: TdxCustomDockControl; DC: HDC; Zone: TdxZone; ARect: TRect; Erasing: Boolean; var Handled: Boolean);
var
  ABrush, AOldBrush: HBRUSH;
begin
  if Zone = nil then Exit;
  ABrush := CreateSolidBrush($FFFFFF);
  AOldBrush := SelectObject(DC, ABrush);
  try
    with ARect do
      PatBlt(DC, Left, Top, Right - Left, Bottom - Top, PATINVERT);
    Handled := True;
  finally
    SelectObject(DC, AOldBrush);
    DeleteObject(ABrush);
  end;
end;

The image below illustrates a docking operation when the event is handled in this manner.

See Also