Jump to content
Registration disabled at the moment Read more... ×
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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×