Recent

Author Topic: Anchors on a child form  (Read 1595 times)

Martin Wynne

  • Newbie
  • Posts: 2
Anchors on a child form
« on: June 03, 2018, 02:45:35 pm »
Hi,

Newbie here. Apologies if this has been answered before, but I couldn't find anything. 

If I create a child form by setting Parent:=other_form; in FormCreate, it cannot be dragged to a new position by the user.

If I then remove the top and left anchors by setting Anchors:=[]; in FormCreate (or in the Object Inspector) so that it can be dragged, I get this exception:

'TWinControl.WMSize loop detected, the widgetset does not like the LCL bounds or sends unneeded wmsize messages'.

I have tried setting

Windows.SetParent(Handle,other_form.Handle);   (instead of Parent:=other_form;)

which removes the exception, but the child form then retains focus after dragging or use, preventing the parent form from responding to the keyboard (which defeats the object of using a child form in the first place).

I'm porting a project to Lazarus from Delphi5, where it works fine. Child forms can be dragged around even with the top and left anchors set.

Thanks for any help in fixing this.

Martin.

jamie

  • Hero Member
  • *****
  • Posts: 2151
Re: Anchors on a child form
« Reply #1 on: June 03, 2018, 06:03:29 pm »
You will need to help out the forms a little, TFORM does not support the MDI interface nor does it work the exact
way as does Delphi, as you have found out.
 
  I believe if you provide a message handler for the WM_NCACTIVE you may be able to override the behavior by
returning it as Handled..

Number 1 at blue screen app creations!

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: Anchors on a child form
« Reply #2 on: June 07, 2018, 04:27:40 am »
@Martin Wynne

Maybe this is what you need:
http://wiki.lazarus.freepascal.org/MultiDoc

Martin Wynne

  • Newbie
  • Posts: 2
Re: Anchors on a child form
« Reply #3 on: June 17, 2018, 10:26:19 pm »
Thanks for the replies. I haven't been able to replicate the Delphi behaviour exactly, so I've decided to live with the Lazarus behaviour for now. It's annoying, but not the end of the world.

Martin.