Recent

Author Topic: Refreshin child after parent is resized  (Read 1389 times)

ACDigital

  • New member
  • *
  • Posts: 6
Refreshin child after parent is resized
« on: August 24, 2021, 07:40:33 pm »
I am trying to create a child form inside a panel on the main form. When doing so, resizing the main form will result in a nasty graphics bug. I'm lost and I am still learning Lazarus/FPC. Can someone point me in the right direction?

Here is the code for creating the child form inside the parent panel:
Code: Pascal  [Select][+][-]
  1.   DateOrderForm := TDateOrderForm.Create(CanvasPanel);
  2.   with DateOrderForm do
  3.   begin
  4.     Parent := CanvasPanel;
  5.     Position:=poDesigned;
  6.     BorderStyle:=bsNone;
  7.     WindowState:=wsFullScreen;
  8.     Align:=alClient;
  9.     Show;
  10.   end;
  11.   currentCanvasForm := DateOrderForm;

I'm also including a picture of the problem I am having.


winni

  • Hero Member
  • *****
  • Posts: 2714
Re: Refreshin child after parent is resized
« Reply #1 on: August 24, 2021, 09:10:59 pm »
Hi!

Your shown source is unclear. Or weird.

Do it that way:

Create Form1
Put a panel on Form1.

Create Form2

Unit1 is your unit for form1.
Unit2 is your unit for form2.

For unit1 do:

Code: Pascal  [Select][+][-]
  1. Unit unit1;
  2. ....
  3. uses ..... , unit2;
  4.  


For unit2 create for the onCreate event:

Code: Pascal  [Select][+][-]
  1. procedure TForm2.FormCreate(Sender: TObject);
  2. begin
  3. Form2.Parent := Form1.Panel1;
  4. Form2.Left := 2;  
  5. Form2.Top := 2;
  6. Form2.Show;
  7. ....
  8. end;
  9.  


For the start of your project:
That is the whole secret.

Winni

PS.:   Forgotten:
Code: Pascal  [Select][+][-]
  1. unit Unit2;
  2. .....
  3. implementation
  4. uses unit1;    
  5. ...
  6.  
:


« Last Edit: August 24, 2021, 09:16:54 pm by winni »

ACDigital

  • New member
  • *
  • Posts: 6
Re: Refreshin child after parent is resized
« Reply #2 on: August 24, 2021, 10:25:17 pm »
Hi!

Your shown source is unclear. Or weird.


Well I tried your example. It worked. However, the problem I was having was that I want to create the form2 from a button click. Thats why I did it the 'weird' way. Is there a better way? Also, the problem was the 'fullscreen' property. It made it so that when I resized the main form I got the graphics glitch.

I would much apreciate a 'better' way of implementng this. Thanks.

 

TinyPortal © 2005-2018