Recent

Author Topic: Problem resizing a form with inside controls  (Read 281 times)

maurobio

  • Full Member
  • ***
  • Posts: 153
Problem resizing a form with inside controls
« on: December 08, 2019, 11:49:08 pm »
Dear ALL,

I have a form containing a tabbed notebook aligned to top, and a panel aligned to bottom, containing a label and a memo.

When I maximize the form, the bottom panel, with the label and the memo, are not resized correspondingly (see the attached screenshot and project files).

I am sure there is some simple trick to solve this, but I could not figure out how to do it.

Any hints and tips will be very welcome!

Cheers,
UCSD Pascal / Burroughs 6700 / Master Control Program
Lazarus 1.9.3/2.0.8 - FPC 3.0.4 on GNU/Linux Mint 19 ("Tessa"), Windows XP SP3, Windows 7 Professional, Windows 10 Home

winni

  • Hero Member
  • *****
  • Posts: 1568
Re: Problem resizing a form with inside controls
« Reply #1 on: December 09, 2019, 12:12:18 am »
Hi!

TPageControl, TTabsheet and TMemo: All three dont have the property autosize.

So you must do it on your own. The correct position is the OnResize event of the Form.

The rest is simple proportional  computing:
In procedure FormOnRezize you get the new size of the form.
The rest is percentage calculation.

As I know you love complicated and CPU time consuming solutions, but I have no idea how to work with regex here. Sorry.

Winni

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: Problem resizing a form with inside controls
« Reply #2 on: December 09, 2019, 12:13:52 am »
Try using the anchor properties of both.  If you want the bottom to take up the extra space, anchor its top & bottom to the top & bottom of the form.  You can see it at work in the IDE.  You may haveto think what should happen if the user reduces the form size.
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

winni

  • Hero Member
  • *****
  • Posts: 1568
Re: Problem resizing a form with inside controls
« Reply #3 on: December 09, 2019, 12:17:02 am »
FormOnResize is also triggered if the user reduces the form size.
The trick you dont have to care is called percentage calculation.



maurobio

  • Full Member
  • ***
  • Posts: 153
Re: Problem resizing a form with inside controls
« Reply #4 on: December 09, 2019, 12:27:29 am »
@winni and @PaulRowntree,

Thanks for your fast and insightful replies.

Are you saying I must do calculations in order to have the controls resized along with the form? But isn't Lazarus, as a fine RAD tool, supposed to do it for me?  :(

I will experiment with your suggestions and play with the autosize property of the components, as well as the anchors.

Cheers,

 
 
UCSD Pascal / Burroughs 6700 / Master Control Program
Lazarus 1.9.3/2.0.8 - FPC 3.0.4 on GNU/Linux Mint 19 ("Tessa"), Windows XP SP3, Windows 7 Professional, Windows 10 Home

maurobio

  • Full Member
  • ***
  • Posts: 153
Re: Problem resizing a form with inside controls
« Reply #5 on: December 09, 2019, 12:32:06 am »
Guys,

Adjusting the up and bottom anchors of the memo did the trick nicely!

Again, thank you very much!

Cheers,
UCSD Pascal / Burroughs 6700 / Master Control Program
Lazarus 1.9.3/2.0.8 - FPC 3.0.4 on GNU/Linux Mint 19 ("Tessa"), Windows XP SP3, Windows 7 Professional, Windows 10 Home

 

TinyPortal © 2005-2018