5

Is there anyway to use the mouse to resize a borderless form in Delphi FMX? I have tried to use OnMouseDown and OnMouseMove and then used the position of the form compared to left and top of the form but I can't make it to work.

For some reason mouse in FMX seems very different from mouse in a normal VCL application.

Shaun Roselt
  • 1,650
  • 5
  • 18
  • 44
user3337132
  • 135
  • 2
  • 6
  • 1
    Add a status bar keeping its `ShowSizeGrip` on True and you're done :) – TLama Feb 21 '14 at 12:19
  • @TLama: please make an answer so we can vote? – whosrdaddy Feb 21 '14 at 15:37
  • @whosrdaddy, sorry, I've been busy with some font stuff... Well, looking at the other question of this user, I don't think it would be a good suggestion. OP seems that want to remove the form border and then put its functionality back to different controls. I don't know the reason for this but isn't there a way to redesign the border somehow ? (if design is the problem) – TLama Feb 21 '14 at 15:57
  • Hi Thanks for your comments. I need to make a note application for a custemor that want no border. I have not tested the method. But can I make the statusbar the same color of the app so the user dont see it - it would be best. – user3337132 Feb 21 '14 at 17:11
  • Why does this question have 4 upvotes? – Toby Allen Aug 08 '15 at 19:11
  • @TobyAllen Because 4 people upvoted it. – Shaun Roselt May 28 '19 at 07:01

2 Answers2

0

In Firemonkey coordinates of the mouse are not anytime relativ of the top / left pixel of the form.

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

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 anything else used as gripsize control.

Add this in your class :

deplacementX, deplacementY: Single;

Those fields are used to calculate the mouvement (increase or decrease the size of the form/frame).

0

If your customer doesn't forbid that, you could change the BorderStyle while runtime in order to make the user able to resize the form like normally. This would make no problems with the resizing and while the user doesn't use this feature, there will be no borders. The user could activate this feature via pressing CTRL + R or you could just make a button or option which activates it.

In my case this works fine, as i just save the new given witdh and height and then adjust the Form.Top and Form.Left to make it look fluid.

Max H.
  • 11
  • 3