Recent

Author Topic: Form move event?  (Read 12083 times)

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Form move event?
« on: November 25, 2014, 05:11:25 pm »
I there a way to detect form move in Lazarus?
I see no form move event.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

sam707

  • Guest
Re: Form move event?
« Reply #1 on: November 25, 2014, 05:16:53 pm »
Try to use OnResize, If I remember it's also called when form is moved

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #2 on: November 25, 2014, 05:20:13 pm »
I tried it, it doesn't get called when the form is moved.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

sam707

  • Guest
Re: Form move event?
« Reply #3 on: November 25, 2014, 05:26:41 pm »
on Windows i used it... oh yup , Ubuntu...

OnChangeBounds then

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #4 on: November 25, 2014, 05:28:53 pm »
Oh yes!! this is the one! Thanks!
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Form move event?
« Reply #5 on: November 25, 2014, 05:34:59 pm »
OnChangeBounds doesn't work here on Linux+Qt.

You can try this:
Add LMessages to uses.
Add this code to form:
Code: [Select]
procedure WMMove(var Message: TLMMove); message LM_MOVE;
...
procedure TForm1.WMMove(var Message: TLMMove);
begin
  inherited WMMove(Message);
  //your code
end;   
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #6 on: November 25, 2014, 06:01:00 pm »
Thank you !
I have MDI application.
I have Lazarus built with Qt and OnChangeBounds works on the MDIParent form.
Doesn't work with MDIChildren.

What I want to do is MDIChildren to stay in the center of their parent.

Edit: WMMove detects the onResize event of the MDIChildren, not the onMove.
« Last Edit: November 25, 2014, 06:11:10 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Form move event?
« Reply #7 on: November 25, 2014, 06:37:02 pm »
these are not working?
Code: [Select]
DefaultMonitor property with
Position property
poMainFormCenter
or
poOwnerFormCenter
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #8 on: November 25, 2014, 06:46:44 pm »
No they don't, I guess because it's an MDI app.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #9 on: November 25, 2014, 07:18:30 pm »
I 'm thinking of abandoning MDI and try with non MDI form to imitate MDI, something like this in the attachment.
Press 'Customers' on the upper left corner for the 'Child' form to show up.
Move and resize the main form.
Tell me what do you think.
(I guess and in the Child form will have to be added handling of it's move event, in fact some way to cancel it's move)
« Last Edit: November 25, 2014, 07:22:21 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Form move event?
« Reply #10 on: November 25, 2014, 08:40:32 pm »
exacute the [MDICustomTest.zip]
provided that you will have a lot more forms to work with
modal forms will produce more problems for you.
if you can
 upload an example of your non working code to be able to help you more
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #11 on: November 25, 2014, 09:32:29 pm »
Ok I will. I'll have to prepare it first.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #12 on: November 27, 2014, 12:52:07 pm »
I 've made an MDI example. (you must have Lazarus built with Qt for the MDI to work)
It has two forms, Customers and CustomersAddNewEdit.
Ok, I can open them in the position I want.
I can also place them in the position I want when main form moved, or resized.
But I can't make the last opened form to stay on top:
Open form 'Customers'.Click 'Add' button. The form 'CustomersAddNewEdit' will open.
Move it and click on the form 'Customers'. It will move on top of the form 'CustomersAddNewEdit'  :(.
« Last Edit: November 27, 2014, 01:14:24 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Form move event?
« Reply #13 on: November 27, 2014, 02:48:08 pm »
i don't have installed Qt to test
but since the popupparent is working as expected
just set the popupparent of your last opened form to previus opened one
frmCustomersAddNewEdit.popupparent:=frmCustomers
is the same as you did with the frmCustomers

Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Form move event?
« Reply #14 on: November 27, 2014, 03:49:09 pm »
Never, I did as you suggested.
It seemed to work.
But when I move the top form (frmCustomersAddNewEdit) and click on frmCustomers, an error happens:
'Project MDIp2_part raised exception class 'External: SIGSEGV'.

 At address B5E8B714'.
« Last Edit: November 27, 2014, 03:53:06 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

 

TinyPortal © 2005-2018