Recent

Author Topic: What contains 'TForm.BaseBounds' ?  (Read 298 times)

Hartmut

  • Hero Member
  • *****
  • Posts: 832
What contains 'TForm.BaseBounds' ?
« on: October 08, 2024, 01:53:48 pm »
The documentation says about this: "The rectangle of the designed bounds". This is not clear enough for me.

I made several tests and in all cases e.g. 'TForm.BaseBounds.Left' was the same as 'TForm.Left' and 'TForm.BaseBounds.Top' was the same as 'TForm.Top' etc. Are these always the same or is it anyhow possible, that these are different? If yes, can you please give an example?

Thanks in advance.

jamie

  • Hero Member
  • *****
  • Posts: 6686
Re: What contains 'TForm.BaseBounds' ?
« Reply #1 on: October 08, 2024, 11:48:33 pm »
Sounds like the Design Time Bounds when you are doing your OI stuff.

The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 12410
Re: What contains 'TForm.BaseBounds' ?
« Reply #2 on: October 09, 2024, 12:30:40 am »
Yes, Jamie is right: Put a panel on a form and anchor all its sides. Then write this OnResize handler for the panel:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1Resize(Sender:TObject);
  2. begin
  3.   Panel1.Caption := Format(
  4.     'Right=%d BaseBounds.Right=%d', [Panel1.Left+Panel1.Width, Panel1.BaseBounds.Right]);
  5. end;
When you now change the width of the form (and of the panel due to the anchoring) by the mouse at runtime you will see that the "Right" value changes accordingly while the Panel.BaseBounds.Right stays always constant at the value of "Right" before you started dragging.

Hartmut

  • Hero Member
  • *****
  • Posts: 832
Re: What contains 'TForm.BaseBounds' ?
« Reply #3 on: October 09, 2024, 11:24:38 am »
Thank you for that demo. I got it to work and saw the difference between 'Panel1.BaseBounds.Right' and 'Panel1.Left+Panel1.Width'.

But my question was more ralated to the properties of a 'TForm'. So I expanded the code to
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1Resize(Sender: TObject);
  2.    begin
  3.    Panel1.Caption := Format(
  4.                      'Right=%d BaseBounds.Right=%d', [Panel1.Left+Panel1.Width,
  5.                      Panel1.BaseBounds.Right]);
  6.    self.Caption := Format(
  7.                      'Right=%d BaseBounds.Right=%d', [self.Left+self.Width,
  8.                      self.BaseBounds.Right]);
  9.    end;
and saw, that there is no difference between 'self.BaseBounds.Right' and 'self.Left+self.Width' when I resize the Form.

So please let me ask again: Are e.g. 'self.BaseBounds.Right' and 'self.Left+self.Width' (where 'self' is a 'TForm') always the same or is it anyhow possible, that these are different? If yes, can you please give an example?

 

TinyPortal © 2005-2018