Jump to content
Ian Branch

Resize a Form vertically only?

Recommended Posts

Hi Team,

Can I allow a Form to resize vertically only, not horizontally at all?

If so, how please?

Regards & TIA,

Ian

Share this post


Link to post

Ah Ha!  Tks haentschman.  I have never used constraints.  I shall have a play.

Share this post


Link to post

There is also an OnConstrainedResize event.

  • Like 1

Share this post


Link to post

In addition to constraining the window's size, you should consider giving the user visual feedback for their attempts to resize.

 

Do this by handling the WM_NCHITTEST message: https://docs.microsoft.com/en-gb/windows/win32/inputdev/wm-nchittest

 

type
  TForm1 = class(TForm)
  protected
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  end;

....

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  inherited;
  case Message.Result of
  HTLEFT,HTRIGHT:
    Message.Result := HTCAPTION;
  HTTOPLEFT,HTTOPRIGHT:
    Message.Result := HTTOP;
  HTBOTTOMLEFT,HTBOTTOMRIGHT:
    Message.Result := HTBOTTOM;
  end;
end;

 

  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×