Lazarus

Using the Lazarus IDE => Designer => Topic started by: tudi_x on December 05, 2016, 03:59:53 pm

Title: [SOLVED] Center 2nd Form on Main Form
Post by: tudi_x on December 05, 2016, 03:59:53 pm
Hi!
I am using the poMainFormCenter option in Lazarus 1.6.2 32b on Windows 7 64b when creating a second form as per attached project.
Unfortunately the second form is not centered to the main form and shows as per attached.
Please advise what I am missing.

Thank you!
Title: Re: Center 2nd Form on Main Form
Post by: mig-31 on December 05, 2016, 04:12:44 pm
Hi,

remove it Form2 from autocreate Form list.

Add code for example to TButton.Onclick:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   AForm2:TForm2;
  4. begin
  5.   AForm2:=TForm2.Create(Self);
  6. end;          
  7.  
Title: Re: Center 2nd Form on Main Form
Post by: tudi_x on December 05, 2016, 05:02:08 pm
Thank you, the form is centered when there is no method on the On Show event.

If I assign a method to the On Show event the second form does not center the main, regardless where the poMainFormCenter option is set, in code or Object Inspector.
Code with method is attached.
Please advise.

Title: Re: Center 2nd Form on Main Form
Post by: davect on December 05, 2016, 05:24:30 pm
Use poOwnerFormCenter instead of poMainFormCenter.
Title: Re: Center 2nd Form on Main Form
Post by: tudi_x on December 05, 2016, 08:25:51 pm
Thank you.
It worked with poOwnerFormCenter, although with some tweaks in some code (ex. use Screen Center in Object Inspector and Owner Form Center in code) and directly in other code.
TinyPortal © 2005-2018