[fpc-pascal] Anchors on a child form
Martin Wynne
martin at templot.com
Mon Jun 4 14:06:54 CEST 2018
Hi Mattias,
Thanks for your reply.
>> 'TWinControl.WMSize loop detected, the widgetset does not like the LCL
>> bounds or sends unneeded wmsize messages'.
>
> Can you create a bug report with an example to reproduce the loop?
Sorry, I don't know how to do that. However, it is very easy to replicate:
1. start a new project application.
2. add an additional new form.
3. in Form2 add:
uses Unit1;
procedure TForm2.FormCreate(Sender: TObject);
begin
Parent:=Form1;
Anchors:=[];
Visible:=True;
end;
4. run it, and the debugger will show the error message.
> Can you give more details, what the Delphi program does?
In Delphi5 setting Parent:=Form1 causes Form2 to behave very similarly
to a TPanel with the addition of some form properties. It has a top
caption bar by means of which it can be dragged around on Form1, a red X
to dismiss it, and it can be resized by dragging the edges/corners.
But it never gains focus or an "Active" border. Focus remains with Form1
at all times. If there are underlined keyboard accelerator keys on its
controls, they are merged with any on Form1 and on any other child forms.
For a graphical drawing program it makes a very useful floating toolbox
which the user can drag around and/or resize to avoid obscuring the
drawing. My application uses several of them, some quite large which
wouldn't fit into a top toolbar.
In Lazarus it initially looks similar, but can't be dragged around and
behaves strangely if resized. I hoped to cure that by removing the
anchors, but then got the error message above.
It can be cured by using Windows.SetParent instead of Parent:=, but now
the child form gains focus and an Active border whenever it is dragged
or its controls are clicked. Which is a nuisance for the user because
the parent form loses focus and the expected keyboard shortcuts no
longer work until the parent form is clicked.
Thanks for any help.
Martin.
More information about the fpc-pascal
mailing list