How can I set the minimum / maximum size?
Applies To: C++Builder 1 or higher
Category: Knowledge Base
- The default C++Builder form can be resized to almost any size. I need to limit this setting. Is it possible?
-
- Start a new project using File | New Application.
-
- Insert in the header file of your form, under public:
-
- MESSAGE void __fastcall MinMax(TMessage &message);
-
- BEGIN_MESSAGE_MAP
- MESSAGE_HANDLER(WM_GETMINMAXINFO, TMessage, MinMax);
- END_MESSAGE_MAP(TForm);
-
- Edit your source code and insert:
-
- MESSAGE void __fastcall TForm1::MinMax(TMessage &message)
- {
- MINMAXINFO *info;
- // Get the size info from the message parameter
- info = (MINMAXINFO *)message.LParam;
-
- // Specify the minimum size
- info->ptMinTrackSize.x = 300;
- info->ptMinTrackSize.y = 300;
-
- // Specify the maximum size
- info->ptMaxTrackSize.x = 400;
- info->ptMaxTrackSize.y = 400;
- }
-
- The WM_GETMINMAXINFO message is sent when a window is about to be resized. You can catch this message and edit its parameters in order to change the default maximum and minimum size.
-
- Notes
- · C++Builder 4 and greater allows you to change directly this option using the Constraints property.
C++Builder Developer's Network
Copyright © Yoto Yotov