Lazarus

Programming => General => Topic started by: rnfpc on June 29, 2019, 08:33:28 am

Title: How to make form/window non-resizable
Post by: rnfpc on June 29, 2019, 08:33:28 am
I am using Lazarus to create a simple gui application with one form only. It has a single button, label and an edit field.

I see that I can adjust name, caption, default text etc. However, I want to make the window fixed in size and not be resizable. I want the resize button at top right also to be disabled. How can I do these adjustments?
Title: Re: How to make form/window non-resizable
Post by: howardpc on June 29, 2019, 09:10:51 am
At least two form properties are useful for you.
Setting BorderStyle to bsDialog will prevent users from altering the window dimensions.
The BorderIcons property controls which system icons are shown. However, its effects vary slightly across platforms, and also depend, IIRC, on whether the form is the project's main form, or a subsidiary form.
Title: Re: How to make form/window non-resizable
Post by: rnfpc on June 29, 2019, 10:03:44 am
Yes, bsDialog worked very well. Thanks.
Title: Re: How to make form/window non-resizable
Post by: lucamar on June 29, 2019, 02:38:45 pm
Setting BorderStyle to bsSingle will do it too and leave you with a normal form, which bsDilaog may not do do.
Title: Re: How to make form/window non-resizable
Post by: andyH on September 24, 2020, 07:51:27 pm
I can confirm bsDialog and bsSingle behave differently.

Home built ubuntu with openbox window mgr, pcmanfm as desktop mgr and lxpanel. With bsDialog when my application ran, the entry in the panel was not showing the correct icon, with bsSingle it behaved 'properly' and showed my application icon in the panel. Both froze the main window size, which was what I wanted.
Title: Re: How to make form/window non-resizable
Post by: Blaazen on September 24, 2020, 08:06:42 pm
You can also use property Form.Constraints (i.e. set MaxWidth=640 and MinWidth=640 etc.)
TinyPortal © 2005-2018