Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking Form size 2

Status
Not open for further replies.

JerryAttrick

Technical User
May 14, 2005
23
NZ
I wish to prevent a user resizing the window/form. I know I have read somewhere how to do it, and I know it's simple stuff, but I'm darned if I can find the reference. I also know there are no such things as silly questions: so how do I do it?

Jerry
BOP NZ
 
Use the .BorderStyle property of TForm. The Help file has a good description of the possible options, but the ones that prevent resizing are bsDialog, bsSingle, bsNone, and bsToolWindow.

-Dell


A computer only does what you actually told it to do - not what you thought you told it to do.
 
Set constraints values for the form. You can se at design time in Object Inspector or at runtime as well. You must set MaxHeight and MinHeight to the same value of the height of your form, same for MaxWidth and MinWidth that must have the value of width's form.

Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
Constraints.MaxHeight := form1.Height ;
Constraints.MinHeight := form1.Height;
Constraints.MaxWidth := form1.Width ;
Constraints.MinWidth := form1.Width ;
end;

Giovanni Caramia
 
‘bsDialog’ certainly locks the size of the window. Unfortunately the menu disappears also. At the same time the Minimise and Maximise buttons disappear as well, but that’s a plus for me in this instance.

I find that ‘bsToolWindow’ setting has very nearly the effect I’m looking for except that the border clings to the group box right-hand and bottom borders, giving a sort of lopsided effect. BTW ‘bsNone’ effect comes into the ‘slightly bizarre’ category, don’t you think?!

I have composed a table of the effects available to me in the Form BorderStyle options but cannot find a way of adequately representing it here. The options appear to be an odd assortment; in some cases the icon (top left) vanishes also.

On my version of Delphi I cannot seem to find help referring to the BorderStyle options in my Help menu.

I think I’ll be trying the 'Constraint' method kindly suggested by Giovanni.

Jerry
BOP NZ
 
Use of constraints may be usefull in other circumstances.
By code you can fix the height and the width of your form to values according your preferences, while, at design time you can work with a bigger form that contains components that you don't like some users use them.
(excuse my poor english, i hope you have understund what i mean)

Giovanni Caramia
 
There's nothing wrong with your English, Giovanni. I understand your meaning, and the option to alter the form at run time, based on criteria like who the user is, or whether the person opts for more complex output etc. is a very good idea. I'll use that in the application I'm working on.

Thanks for your help.

Jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top