So sollte es gehen (Die Message-Struktur für WM_SIZING entspricht der für WM_MOVING):
Delphi-Quellcode:
...
protected
procedure WMMoving(var Message: TWMMoving); message WM_MOVING;
procedure WMSizing(var Message: TWMMoving); message WM_SIZING;
...
{ Das Form soll oben einen Rand von 100 lassen. }
procedure TForm300.WMMoving(var Message: TWMMoving);
var
DY: Integer;
begin
DY := 100 - Message.DragRect.Top;
if DY > 0 then begin
Message.DragRect.Top := 100;
Message.DragRect.Bottom := Message.DragRect.Bottom + DY;
end;
inherited;
end;
procedure TForm300.WMSizing(var Message: TWMMoving);
begin
if Message.DragRect.Top < 100 then begin
Message.DragRect.Top := 100;
end;
inherited;
end;