Recent

Author Topic: ChildSizing -don't work runtime  (Read 1023 times)

J-23

  • Full Member
  • ***
  • Posts: 108
ChildSizing -don't work runtime
« on: April 26, 2020, 11:31:44 pm »
Hello,
Why doesn't the "Layout" function from the "Childsize" subset work for components created at run time?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   FFormEditor: TForm;
  4.   FHeaderPanel: TPanel;
  5.   FHederText: TLabel;
  6.   FDescriptionText: TLabel;
  7.   FFormFooter: TBevel;
  8.   FCenterPanel: TPanel;
  9.   FGroupBoxLazarus: TGroupBox;
  10.   FGroupBoxComponent: TGroupBox;
  11. begin
  12.   FFormEditor := TForm.CreateNew(Application);
  13.   FFormEditor.Caption := 'Palette Editor';
  14.   FFormEditor.Height := 600;
  15.   FFormEditor.Width := 400;
  16.   FFormEditor.Position := poDesktopCenter;
  17.   FFormEditor.BorderStyle := bsSingle;
  18.   FFormEditor.BorderIcons := [biSystemMenu];
  19.  
  20.   FCenterPanel := TPanel.Create(FFormEditor);
  21.   FCenterPanel.BevelInner := bvNone;
  22.   FCenterPanel.BevelOuter := bvNone;
  23.   FCenterPanel.Align := alClient;
  24.   FCenterPanel.ChildSizing.EnlargeHorizontal := crsScaleChilds;
  25.   FCenterPanel.ChildSizing.EnlargeVertical := crsScaleChilds;
  26.   FCenterPanel.Parent := FFormEditor;
  27.  
  28.   FGroupBoxLazarus := TGroupBox.Create(FCenterPanel);
  29.   FGroupBoxLazarus.Align := alClient;
  30.   FGroupBoxLazarus.Caption := 'Lazarus Palette';
  31.   FGroupBoxLazarus.Parent := FCenterPanel;
  32.  
  33.  
  34.   FGroupBoxComponent := TGroupBox.Create(FCenterPanel);
  35.   FGroupBoxComponent.Align := alClient;
  36.   FGroupBoxComponent.Caption := 'Component Palette';
  37.   FGroupBoxComponent.Parent := FCenterPanel;
  38.  
  39.   FFormFooter := TBevel.Create(FFormEditor);
  40.   FFormFooter.Shape := bsTopLine;
  41.   FFormFooter.Align := alBottom;
  42.   FFormFooter.Parent := FFormEditor;
  43.  
  44.   FHeaderPanel := TPanel.Create(FFormEditor);
  45.   FHeaderPanel.BevelInner := bvNone;
  46.   FHeaderPanel.BevelOuter := bvNone;
  47.   FHeaderPanel.Align := alTop;
  48.   FHeaderPanel.Color := clWindow;
  49.   FHeaderPanel.Parent := FFormEditor;
  50.  
  51.   FHederText := TLabel.Create(FHeaderPanel);
  52.   FHederText.Caption := FFormEditor.Caption;
  53.   FHederText.Font.Color := clBlack;
  54.   FHederText.Font.Style := [fsBold];
  55.   FHederText.Top := 8;
  56.   FHederText.Left := 8;
  57.   FHederText.Parent := FHeaderPanel;
  58.  
  59.   FDescriptionText := TLabel.Create(FHeaderPanel);
  60.   FDescriptionText.Caption := 'Component palette configuration';
  61.   FDescriptionText.Top := FHederText.Height + 4;
  62.   FDescriptionText.Left := 16;
  63.   FDescriptionText.Parent := FHeaderPanel;
  64.   FFormEditor.Show;
  65.   FCenterPanel. ChildSizing.Layout := cclLeftToRightThenTopToBottom; -- this don't work
  66. end;
  67.  

If we create the form with the IDE designer then everything works fine.

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: ChildSizing -don't work runtime
« Reply #1 on: April 27, 2020, 12:07:14 am »
interesting looking code I might add..

 have you tried setting that property before adding any child controls to the Tpanel ?

Its very possible that is a one time set..
in other words it doesn't  reorganize the child controls when set after the fact.

 This is just a theory on my part ..
 :(

The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: ChildSizing -don't work runtime
« Reply #2 on: April 27, 2020, 12:15:20 am »
Hi!

FFormEditor has no childsizing!

Winni

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: ChildSizing -don't work runtime
« Reply #3 on: April 27, 2020, 12:31:04 am »
But its a TPanel he is doing this with.. and it has it..
I don't know
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: ChildSizing -don't work runtime
« Reply #4 on: April 27, 2020, 01:17:42 am »
Do not align the children of the FCenterPanel to which you want to apply ChildSizing

Code: Pascal  [Select][+][-]
  1.   ...
  2.   FGroupBoxLazarus := TGroupBox.Create(FCenterPanel);
  3.   //FGroupBoxLazarus.Align := alClient;  // <--- REMOVED
  4.   FGroupBoxLazarus.Caption := 'Lazarus Palette';
  5.   FGroupBoxLazarus.Parent := FCenterPanel;
  6.  
  7.   FGroupBoxComponent := TGroupBox.Create(FCenterPanel);
  8.   //FGroupBoxComponent.Align := alClient;   // < --- REMOVED
  9.   FGroupBoxComponent.Caption := 'Component Palette';
  10.   FGroupBoxComponent.Parent := FCenterPanel;
  11.   ...
  12.  

J-23

  • Full Member
  • ***
  • Posts: 108
Re: ChildSizing -don't work runtime
« Reply #5 on: April 27, 2020, 02:15:41 am »
Do not align the children of the FCenterPanel to which you want to apply ChildSizing

Code: Pascal  [Select][+][-]
  1.   ...
  2.   FGroupBoxLazarus := TGroupBox.Create(FCenterPanel);
  3.   //FGroupBoxLazarus.Align := alClient;  // <--- REMOVED
  4.   FGroupBoxLazarus.Caption := 'Lazarus Palette';
  5.   FGroupBoxLazarus.Parent := FCenterPanel;
  6.  
  7.   FGroupBoxComponent := TGroupBox.Create(FCenterPanel);
  8.   //FGroupBoxComponent.Align := alClient;   // < --- REMOVED
  9.   FGroupBoxComponent.Caption := 'Component Palette';
  10.   FGroupBoxComponent.Parent := FCenterPanel;
  11.   ...
  12.  
That's right, thanks.

 

TinyPortal © 2005-2018