Recent

Author Topic: Form move event  (Read 946 times)

Borneq

  • Full Member
  • ***
  • Posts: 238
Form move event
« on: January 28, 2020, 03:08:33 pm »
Is possible detect if form is moved?  I ca'nt font OnMove event nor WM_MOVE message.
Problem is when I open popup form not modal but always on top. When I move basic form, popup form should close or also move.
If I set popup form as child - it can't go beyond parent form.
« Last Edit: January 28, 2020, 03:12:23 pm by Borneq »

wp

  • Hero Member
  • *****
  • Posts: 6722
Re: Form move event
« Reply #1 on: January 28, 2020, 03:14:08 pm »
There is an OnChangeBounds event of the form:

Code: Pascal  [Select]
  1. procedure TForm1.FormChangeBounds(Sender: TObject);
  2. begin
  3.   Caption := Format('L = %d, T = %d, W = %d, H = %d', [Left, Top, Width, Height]);
  4. end;  
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Borneq

  • Full Member
  • ***
  • Posts: 238
Re: Form move event
« Reply #2 on: January 28, 2020, 04:17:53 pm »
I try first form with Edit, and second popup form, but is problem: popup should hide if edit or first form is deactivated, but it can be possible click on second form and use scrollbars.
My next attempt: two forms, second popup form has list and edit both.
Best solution would be is second form was child of first form, but is impossible popup go beyond first form?
Third attempt: big transparent form with two child forms?

Borneq

  • Full Member
  • ***
  • Posts: 238
Re: Form move event
« Reply #3 on: January 28, 2020, 06:43:22 pm »
Is posssible make resizable child control ? for example resizable panel? not resize after resizing form, but in reverse - form change it size to fit panel?

lucamar

  • Hero Member
  • *****
  • Posts: 2402
Re: Form move event
« Reply #4 on: January 28, 2020, 06:57:26 pm »
Is posssible make resizable child control ? for example resizable panel? not resize after resizing form, but in reverse - form change it size to fit panel?

I'm not sure whether it'll work but you can try setting the child form's Align property. But note that forms are not really designed for this kind of operation (i.e. making them children of other controls). Frames are most suited to this; it's in fact their raison d'être :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

jamie

  • Hero Member
  • *****
  • Posts: 2312
Re: Form move event
« Reply #5 on: January 28, 2020, 10:51:59 pm »
Is posssible make resizable child control ? for example resizable panel? not resize after resizing form, but in reverse - form change it size to fit panel?

Place a TPanel on the form. Place a TSplitter beside it. Go into  the Anchor editor and have the Panel anchor to the splitter..

When you move the splitter the panel will size with it.
Number 1 at blue screen app creations!