Skip to main content

Resizing Bar Custom Painting Sample

  • 2 minutes to read

You have the following options to paint a resizing bar that is displayed when resizing dock controls:

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

The sample code below handles the docking manager’s OnCustomDrawResizingSelection event. For horizontal resizing operations, the resizing bar is painted in the default manner. For vertical resizing operations, the resizing bar is painted using an inverse texture brush.

procedure TForm1.dxDockingManager1CustomDrawResizingSelection(Sender: TdxCustomDockControl; DC: HDC; Zone: TdxZone; ARect: TRect; Erasing: Boolean; var Handled: Boolean);
var
  ABrush, AOldBrush: HBRUSH;
  Bitmap: TBitmap;
begin
  if Zone.Direction = zdVertical then Exit;
  Bitmap := TBitmap.Create;
  Bitmap.LoadFromFile('d:\SelectionBarTexture.bmp');
  ABrush := CreatePatternBrush(Bitmap.Handle);
  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);
    Bitmap.Free;
  end;
end;

The image below shows the resulting appearance of the resizing bar.

The following image shows a bitmap that was used as the brush’s pattern. (The image is magnified four times. A red border was not used – it simply shows image boundaries.)

See Also