Delphi FMX resizes borderless with the mouse

Is there a way to use the mouse to resize borderless shapes in Delphi FMX? I tried to use OnMouseDownand OnMouseMovethen used the position of the form compared to the left and top of the form, but I cannot get it to work.

For some reason, the mouse in FMX is very different from the mouse in a regular VCL application.

+4
source share
2 answers

In Firemonkey coordinates, the mouse does not relate the top / left pixel of the form at any time.

You can use the functions to convert them and simulate a sizegrip file with this code:

procedure TFenetre.btnRedimensionneMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  if (ssLeft in Shift) then
  begin
    deplacementX := X;
    deplacementY := Y;
  end;
end;

procedure TFenetre.btnRedimensionneMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Single);
begin
  if (ssLeft in Shift) then
  begin
    Self.width := Self.width - deplacementX + X;
    Self.height := Self.height - deplacementY + Y;
  end;
end;

btnRedimensionne is a button, image, or something else used to control capture.

Add this to your class:

deplacementX, deplacementY: Single;

( /).

0

, BorderStyle , , . , , . , CTRL + R, , .

, witdh height, Form.Top Form.Left, .

0

All Articles