Is there any way to stop the user resizing the form?
Currently I am using:
When form size changed….
MainForm.Height := 761;
MainForm.Width := 777;
But this looks horrible as it flickers as the user tries to change the form size.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Fixing the size is easy, you have two options:
Delphi forms have a
BorderStyleproperty and aBorderIconsproperty. If you setBorderStyletobsDialog, andBorderIconstobiSystemMenuonly, user can not resize the form.You can specify value to
Constraintsproperty. If you write the same number toMinWidthandMaxWidth, the width will be fixed.Preventing move is more tricky. I can come up with only these solutions now:
Set
BorderStyletobsNone. You will need to draw the form caption yourself, if needed.Write a message handler to
WM_NCHITTEST, call inherited first, then check theMessage.ResultforHTCAPTION. If it isHTCAPTION, set it toHTCLIENTinstead. This way, you fool Windows to think the user didn’t click on caption, so he will not be able to drag. Please try if the user can still move the window opening the system menu, and choosing Move. If so, you have to hide the system menu too (BorderIcons).Answer found here.