DrawFocusRect function

In a picture, I want to draw a selection area with a circular shape. I used to draw rectangular shape but never dealt with any other. Is it possible to be done ? I am coding in Delphi

728x90

1 Answers DrawFocusRect function

DrawFocusRect() supports rectangles only. For other shapes, you will have to manually draw them yourself as desired, such as with Ellipse() with an appropriate Brush and Pen.

To have similar appearance and behavior with DrawFocusRect(), use an alternating and XOR pen. E.g.:

var
  Brush: TLogBrush;
begin
  Brush.lbStyle := BS_SOLID;
  Brush.lbColor := clBlack;
  Canvas.Pen.Handle := ExtCreatePen(PS_COSMETIC or PS_ALTERNATE, 1, Brush, 0, nil);
  Canvas.Pen.Style := psAlternate;
  Canvas.Pen.Mode := pmNotXor;
  Canvas.Brush.Style := bsClear;
  Canvas.Ellipse(...

4 months ago