Board index » delphi » Getting Form.Width during resizing with mouse ?

Getting Form.Width during resizing with mouse ?

Hi out there,

i want to limit the resizing of a form with minimum and maximum values. How
can my prog recognize, when a form is getting  let's say smaller than 400
an how can resizing then stopped immediately. The 'OnResize -event' can
only react when all has happened and restore to a size of 400. I think that
this can be done better, or what ?

I would be grateful for hints.

Greetings

Gerd

--
please remove -nomorespam-

 

Re:Getting Form.Width during resizing with mouse ?


please a WM_SIZE  message in your forms Object..

you need to check the size of the parms, if they are ok then process the
inherited , else of not then reset the parms to the size you want it to be
then
process the inherited..

   procedure  WMSIZE(var msg:Tmessage); message WM_SIZE;

procedure TFORM1.WMSIZE(Var msg:Tmessage);
 Begin
   { now at this point check the parms of the message}
  { if the message is ok then process the inherited...}
  if  (Lo( msg.lparm) > 400)or(Hi(msg.lparm > 300)) Then
   Begin
    Lo(Msg.Lparm) := 400;
    Hi(Msg.Lparm):=  300;
   end;
 inherited;
End;
i may need to treak this but it is a good model to start with..

Gerd Volk <gv...@nomorespam.metronet.de> wrote in article
<01bdaf6c$d18ab860$LocalHost@default>...

Quote

> Hi out there,

> i want to limit the resizing of a form with minimum and maximum values.
How
> can my prog recognize, when a form is getting  let's say smaller than 400
> an how can resizing then stopped immediately. The 'OnResize -event' can
> only react when all has happened and restore to a size of 400. I think
that
> this can be done better, or what ?

> I would be grateful for hints.

> Greetings

> Gerd

> --
> please remove -nomorespam-

Re:Getting Form.Width during resizing with mouse ?


Gerd,
have a look at Delphi3.HLP and search for WM_SIZE. There is even an example
on how to do it.

-----------------------------------
Hope [this] helps.
Arne Schaepers
Gerd Volk schrieb in Nachricht <01bdaf6c$d18ab860$LocalHost@default>...

Quote

>Hi out there,

>i want to limit the resizing of a form with minimum and maximum values. How
>can my prog recognize, when a form is getting  let's say smaller than 400
>an how can resizing then stopped immediately. The 'OnResize -event' can
>only react when all has happened and restore to a size of 400. I think that
>this can be done better, or what ?

>I would be grateful for hints.

>Greetings

>Gerd

>--
>please remove -nomorespam-

Re:Getting Form.Width during resizing with mouse ?


Process the WM_GETMINMAXINFO message.

TForm1=class(TForm)
  protected
    procedure WMGetMinMaxInfo( var MSG : TMessage ); message WM_GETMINMAXINFO;
end;

procedure TForm1.WMGetMinMaxInfo( var MSG : TMessage );
const
  FORM_MAX_WIDTH  = 800;
  FORM_MAX_HEIGHT = 600;
  FORM_MIN_WIDTH  = 600;
  FORM_MIN_HEIGHT = 400;
begin
  with PMinMaxInfo(MSG.lparam)^ do
  begin
    ptMaxTrackSize.x := FORM_MAX_WIDTH;
    ptMaxTrackSize.y := FORM_MAX_HEIGHT;
    ptMinTrackSize.x := FORM_MIN_WIDTH;
    ptMinTrackSize.y := FORM_MIN_HEIGHT;
  end;
end;

regards,
Barry

In article <01bdaf6c$d18ab860$LocalHost@default>,
  "Gerd Volk" <gv...@nomorespam.metronet.de> wrote:

Quote

> Hi out there,

> i want to limit the resizing of a form with minimum and maximum values. How
> can my prog recognize, when a form is getting  let's say smaller than 400
> an how can resizing then stopped immediately. The 'OnResize -event' can
> only react when all has happened and restore to a size of 400. I think that
> this can be done better, or what ?

> I would be grateful for hints.

> Greetings

> Gerd

> --
> please remove -nomorespam-

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Other Threads