Board index » delphi » A minimum size for a form...

A minimum size for a form...

Hi all,

I'd like to know if there is a way to set a minimum size for a form.
Just consider as an example the Delphi interface. You can resize it
horizontally until a certain size, and you can resize it at all
vertically. That's the kind of thing I'd like to have in my appliaction.
But so far, the only way I succeeded to set it up is to use the OnResize
event. And then to check the Height and Width properties. But the effect
is really bad, though it was the expected result.

Anyway, if someone has a solution to my problem, then I'll be really
pleased if he/she can reply to this message.

        Regards,

--
Alan GARNY                              http://www.physiol.ox.ac.uk/~gry
University Laboratory of Physiology       Job Phone: +44 (0)1865 272-501
Parks Road                                 Job  Fax: +44 (0)1865 272-554
Oxford, OX1-3PT, UK                      Home Phone: +44 (0)1865 370-240

 

Re:A minimum size for a form...


Quote
Alan GARNY (g...@physiol.ox.ac.uk) wrote:
> I'd like to know if there is a way to set a minimum size for a
> form.  ...the only way I succeeded to set it up is to use the
> OnResize event. And then to check the Height and Width properties.
> But the effect is really bad, though it was the expected result.

You could trap the WM_WINDOWPOSChanging message and adjust the
window size there.  Thus avoiding those redundant repaints I  
guess you are talking about.

  TForm1 = class( TForm)
    :
    procedure WMWindowsPosChanging( var msg : TWMWindowPosChanging);
              message WM_WINDOWPOSChanging;
    :
  end;

  procedure TForm1.WMWindowsPosChanging
    (var msg : TWMWindowPosChanging);
  begin
    with msg.windowPos^ do
    begin
      if cx < 100 then cx := 100;
      if cy < 100 then cy := 100;
    end;
    inherited;
  end;

--
Dag Garthus
dag.gart...@eunet.no

Re:A minimum size for a form...


Quote
Alan GARNY <g...@physiol.ox.ac.uk> wrote:
>Hi all,
>I'd like to know if there is a way to set a minimum size for a form.
>Just consider as an example the Delphi interface. You can resize it
>horizontally until a certain size, and you can resize it at all
>vertically. That's the kind of thing I'd like to have in my appliaction.
>But so far, the only way I succeeded to set it up is to use the OnResize
>event. And then to check the Height and Width properties. But the effect
>is really bad, though it was the expected result.
>Anyway, if someone has a solution to my problem, then I'll be really
>pleased if he/she can reply to this message.
>    Regards,
>--
>Alan GARNY                              http://www.physiol.ox.ac.uk/~gry
>University Laboratory of Physiology       Job Phone: +44 (0)1865 272-501
>Parks Road                                 Job  Fax: +44 (0)1865 272-554
>Oxford, OX1-3PT, UK                      Home Phone: +44 (0)1865 370-240

You do it like this.  By the way it works GREAT.  Especially compared
to half-way measures like putting code in form.resize.  This will set
both a minumum and a maximum tracking size for the form.  Try it I
think you will really like this.

Put a declaration in private or wherever like this:
          private
        { Private declarations }
                 procedure WMGetMinMaxInfo(Var Message :
TWMGetMinMaxInfo);message       WM_GETMINMAXINFO;

Then type in a procedure like this below.

        procedure TForm1.WMGetMinMaxInfo(Var Message :
TWMGetMinMaxInfo);
        begin
           Message.MinMaxInfo^.ptMaxTrackSize.x := 350;{350x290 max}
           Message.MinMaxInfo^.ptMaxTrackSize.y := 290;
           Message.MinMaxInfo^.ptMinTrackSize.x := 170; {170x170 min}
           Message.MinMaxInfo^.ptMinTrackSize.y := 170;
        end;

Eric Miles
e...@pobox.com
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
My opinions and comments are my own and ONLY
my own and reflect in no way my employer's.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Re:A minimum size for a form...


Quote
Alan GARNY <g...@physiol.ox.ac.uk> wrote:
>Hi all,

>I'd like to know if there is a way to set a minimum size for a form.
>Just consider as an example the Delphi interface. You can resize it
>horizontally until a certain size, and you can resize it at all
>vertically. That's the kind of thing I'd like to have in my appliaction.
>But so far, the only way I succeeded to set it up is to use the OnResize
>event. And then to check the Height and Width properties. But the effect
>is really bad, though it was the expected result.

Hello Alan,

Use WM_GETMINMAXINFO message.

If you still have problem email me,
Pawel

--
\||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||/
-         Pawel Ksiezyk     ksie...@bull.mimuw.edu.pl        -
-    Institute of Informatics   Warsaw University   Poland   -
/||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\

Other Threads