Recent

Author Topic: Clean form resize  (Read 3038 times)

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Clean form resize
« on: March 27, 2026, 06:34:42 pm »
Hello, I want my application's items, such as text, buttons, text fields, cboBoxes etc. resize along with the application being resized. I would prefer resizing when user fullscreens/drags the window to change size, but ultimately a set resoultion changed via button click would be fine too.

Please keep in mind that I am still a beginner in Free Pascal. However, I will try to learn and understand any submissions.

Thank you for your time!  :)
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

LemonParty

  • Hero Member
  • *****
  • Posts: 524
Re: Clean form resize
« Reply #1 on: March 27, 2026, 06:48:12 pm »
You can anchor items to the form and they will be resized automatically.
Drop on a form some control, right click on it, select "Anchor Editor".
For more information https://wiki.freepascal.org/Anchor_Sides
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Re: Clean form resize
« Reply #2 on: March 27, 2026, 06:53:19 pm »
If I want my items to resize accordingly to window, do I need to select all anchors (top left, top right, bottom left, bottom right)?
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

LemonParty

  • Hero Member
  • *****
  • Posts: 524
Re: Clean form resize
« Reply #3 on: March 27, 2026, 07:02:55 pm »
Yes. And specify your form in sibling.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1285
Re: Clean form resize
« Reply #4 on: March 29, 2026, 12:46:26 am »
Hello, I want my application's items, such as text, buttons, text fields, cboBoxes etc. resize along with the application being resized. I would prefer resizing when user fullscreens/drags the window to change size, but ultimately a set resoultion changed via button click would be fine too.

Please keep in mind that I am still a beginner in Free Pascal. However, I will try to learn and understand any submissions.

Thank you for your time!  :)

Following is basic information about anchoring your components on form:

https://wiki.freepascal.org/GUI_design_guidelines

https://wiki.freepascal.org/IDE_Window:_Anchor_Editor

https://wiki.freepascal.org/Anchor_Sides

https://wiki.freepascal.org/Example:_Anchors._How_to_reliably_align_dynamically_created_controls_under_changing_visibility

Zvoni

  • Hero Member
  • *****
  • Posts: 3396
Re: Clean form resize
« Reply #5 on: March 30, 2026, 08:42:17 am »
Be aware, that anchors ALONE won't work, if you have multiple controls (e.g. Listboxes) side-by-side, and you want them to resize according to the ratio they have to each other.
In that case, "manual" calculation is necessary
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

mas steindorff

  • Hero Member
  • *****
  • Posts: 587
Re: Clean form resize
« Reply #6 on: March 30, 2026, 08:55:17 pm »
Fonts are a bit harder to grow and skink for a beginner. let me suggest a simple FontDialog example.
Drag and drop a FontDialog component from the Dialogs collection onto your form. then have a menu item from a popup menu or your main menu call something like
Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.MnuFontClick(Sender: TObject);
  2. begin
  3.   FontDialog1.Font := Memo1.Font;
  4.   if (FontDialog1.Execute()) then begin
  5.      memo1.Font    := FontDialog1.Font;
  6.      end;
  7. end;
  8.  

Here I just updated the memo but you can update any of your other visible component  on your form.
I tend to pair this up with "sessionProperties" component  to save the new font selection from one run to the next but that is another topic.
MAS
 
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Re: Clean form resize
« Reply #7 on: March 31, 2026, 07:39:06 pm »
Be aware, that anchors ALONE won't work, if you have multiple controls (e.g. Listboxes) side-by-side, and you want them to resize according to the ratio they have to each other.
In that case, "manual" calculation is necessary

I want every element to resize based on window size, but thanks for the heads-up.
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Re: Clean form resize
« Reply #8 on: March 31, 2026, 07:40:41 pm »
Here I just updated the memo but you can update any of your other visible component  on your form.
I tend to pair this up with "sessionProperties" component  to save the new font selection from one run to the next but that is another topic.
MAS
 

Thanks for the example, though maybe I'll manage without font resizing or just have a few set resolutions - each resolution will set different font size incementer (I have a few different font sizes in my form).
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

 

TinyPortal © 2005-2018